/***************************************************************************
创建者：　华磊
 开始时间：               : 2020.11.16
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   程序指令视窗测试用代理类
*                                                                         *
 ***************************************************************************/
#include "../ProgramLanguageTranslate/programlanguagetranslate.h"
#include "programdelegate.h"
#include <QDebug>
#include "../FtpManage/ftpmanage.h"
#include "../CommunicateDelegate/communicatenormaldelegate.h"
#include "hmicommondefine.h"
#include "instructionEnum.h"
#include "programregexp.h"
#include "weldpropertydialog.h"
#include "weldconditiondialog.h"
#include "../programView/buttonfunctionmap.h"
#include "weavemotionconditiondialog.h"

extern FtpManage *ftpManage;
extern FileData fileData;

ProgramDelegate::ProgramDelegate(CommunicateNormalDelegate *communicateNormalDelegateIn,
                                 ProgramLanguageTranslate *programLanguageTranslateIn,
                                 ProgramView *programViewIn, GlobalData *globalDataIn,
                                 MoveOperation *moveOperationIn, GlobalData *ioDataIn,
                                 MapView *mapViewIn, QObject *parent):
        QObject(parent)
{
    communicateNormalDelegate=communicateNormalDelegateIn;
    programLanguageTranslate=programLanguageTranslateIn;
    globalData = globalDataIn;
    programView=programViewIn;
    moveOperation = moveOperationIn;
    ioData=ioDataIn;
    mapView=mapViewIn;

    programRegExp=new ProgramRegExp;
    instructionListViewFlag = 0;

    defaultJMoveSpeed=100;
    defaultLMoveSpeed=100;
    defaultUniteType="%";

    currentProgram.clear();  //tr("dd请求");

    maxUsedPointIndex = 1;

    getFileAddress = "/";//文件浏览器路径

    ftpGetSaveProgramFileFlag = false;

    timerOrder = new QTimer;
    QObject::connect(timerOrder,SIGNAL(timeout()),this,SLOT(timeOrderWork()));
    timerOrder->start(800);
    initConnect();
    initialView();
}

ProgramDelegate::~ProgramDelegate()
{

}

void ProgramDelegate::initConnect()
{
    initialConnectButtonFunc();
    //指令内容中英文显示
    connect(programView, SIGNAL(showFileInfoChineseSignal()), this, SLOT(showFileInfoChineseSlot()));

    connect(programView, SIGNAL(moveUpInstruction(int)), this, SLOT(moveUpInstructionSlot(int)));
    connect(programView, SIGNAL(moveDownInstruction(int)), this, SLOT(moveDownInstructionSlot(int)));
    connect(programView, SIGNAL(deleteInstruction(int)), this, SLOT(deleteInstructionSlot(int)));
    connect(programView, SIGNAL(noteInstruction(int)), this, SLOT(noteInstructionSlot(int)));
    connect(programView, SIGNAL(recordPoint(int)), this, SLOT(recordPointSlot(int)));
    connect(programView, SIGNAL(showPoint(QString)), this, SLOT(showPointSlot(QString)));
    connect(programView, SIGNAL(jToPoint(int)), this, SLOT( jToPointSlot(int)));
    connect(programView, SIGNAL(lToPoint(int)), this, SLOT(lToPointSlot(int)));
    connect(programView, SIGNAL(stopPointMove()),this,SLOT(stopMoveToPointSlot()));
    connect(programView->pointViewDialog, SIGNAL(jMoveSignal(int)),this,SLOT(pointViewjMoveSlot(int)));
    connect(programView->pointViewDialog, SIGNAL(lMoveSignal(int)),this,SLOT(pointViewlMoveSlot(int)));
    connect(programView->pointViewDialog, SIGNAL(moveStopSignal()),this,SLOT(stopMoveToPointSlot()));
    connect(programView->pointViewDialog, SIGNAL(recordPoint(int)),this,SLOT(recordPointSlotByPointNum(int)));
    connect(programView->pointViewDialog, SIGNAL(changePointTypeToJoint(int)),this,SLOT(changePointToDegSlot(int)));
    connect(programView->pointViewDialog, SIGNAL(changePointTypeToCartesian(int)),this,SLOT(changePointToWorldSlot(int)));

    // 指令列表界面选择自由导航指令载入当前点位
    connect(programView, SIGNAL(recordDPointSignal(int)), programView->moveFreeInstructionDelegate, SLOT(recordDPointSlot(int)));

    //connect(programView, SIGNAL(saveFile(QString, QStringList)), this, SLOT(saveFileSlot(QString, QStringList)));
    connect(programView, SIGNAL(saveFileSignal()),this,SLOT(saveFileSlot()));
    connect(programView->programSaveDialog, SIGNAL(saveFileSignal()),this,SLOT(saveFileSlot()));

    connect(programView, SIGNAL(menuViewShowOrHide(int)), this, SLOT(menuViewShowOrHideSlot(int)));
    //connect(programView, SIGNAL(menuChange(int)), this, SLOT(menuChangeSlot(int)));
    connect(programView, SIGNAL(menuChange()), this, SLOT(menuChangeSlot()));

    //InstructionMenu
    connect(programView->instructionMenu_usualyUsed2, SIGNAL(oftenForwardPage()), this, SLOT(oftenForwardPageSlot()));
    connect(programView->instructionMenu_usualyUsed1, SIGNAL(oftenNextPage()), this, SLOT(oftenNextPageSlot()));


    //InstructionAll
    connect(programView->instructionMenu_all, SIGNAL(allForwardPage()), this, SLOT(allForwardPageSlot()));
    connect(programView->instructionMenu_all, SIGNAL(allNextPage()), this, SLOT(allNextPageSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openMoveMenu()), this, SLOT(openMoveMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openPalletMenu()), this, SLOT(openPalletMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openFlowMenu()), this, SLOT(openFlowMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openRegisterMenu()), this, SLOT(openRegisterMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openIoMenu()), this, SLOT(openIoMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openOtherMenu()), this, SLOT(openOtherMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openStampingMenu()), this, SLOT(openStampingMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openWeldMenu()), this, SLOT(openWeldMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(waitInstruction()), this, SLOT(waitInstructionSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openGuidanceMenu()), this, SLOT(openGuidanceMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openModbusMenu()), this, SLOT(openModbusMenuSlot()));
    connect(programView->instructionMenu_all, SIGNAL(openTCPCommunicationMenu()), this, SLOT(openTcpCommunicationSlot()));

    // GuidanceMenu
    connect(programView->guidanceMenu, SIGNAL(moveMagInstruction()), this, SLOT(guidanceMoveMagSlot()));
    connect(programView->guidanceMenu, SIGNAL(moveFreeInstruction()), this, SLOT(guidanceMoveFreeSlot()));
    connect(programView->guidanceMenu, SIGNAL(guidanceForwardPageSignal()), this, SLOT(guidanceForwardPageSlot()));
    connect(programView->guidanceMenu, SIGNAL(guidanceNextPageSignal()), this, SLOT(guidanceNextPageSlot()));
    connect(programView->guidanceMenu, SIGNAL(guidanceSetOdomResetSlot()), this, SLOT(setOdomResetSlot()));

    // ModbusMenu
    connect(programView->modbusMenu, SIGNAL(modbusStartInstruction()), this, SLOT(modbusStartSlot()));
    connect(programView->modbusMenu, SIGNAL(modbusReadInstruction()), this, SLOT(modbusReadSlot()));
    connect(programView->modbusMenu, SIGNAL(modbusWriteInstruction()), this, SLOT(modbusWriteSlot()));
    connect(programView->modbusMenu, SIGNAL(modbusForwardPage()) , this, SLOT(modbusForwardPageSlot()));
    connect(programView->modbusMenu, SIGNAL(modbusNextPage()), this, SLOT(modbusNextPageSlot()));

    // TCP Communication Menu
    connect(programView->tcpCommunicationMenu, SIGNAL(TCP_StartSignal()), this, SLOT(tcpStartSlot()));
    connect(programView->tcpCommunicationMenu, SIGNAL(TCP_ReadSignal()), this, SLOT(tcpReadSlot()));
    connect(programView->tcpCommunicationMenu, SIGNAL(TCP_WriteSignal()), this, SLOT(tcpWriteSlot()));
    connect(programView->tcpCommunicationMenu, SIGNAL(forwardPageSignal()), this, SLOT(tcpForwardPageSlot()));
    connect(programView->tcpCommunicationMenu, SIGNAL(nextPageSignal()), this, SLOT(tcpNextPageSlot()));

    //MoveMenu
    connect(programView->moveMenu, SIGNAL(moveForwardPage()), this, SLOT(moveForwardPageSlot()));
    connect(programView->moveMenu, SIGNAL(moveNextPage()), this, SLOT(moveNextPageSlot()));
    connect(programView->moveMenu, SIGNAL(jInstruction()), this, SLOT(jInstructionSlot()));
    connect(programView->moveMenu, SIGNAL(lInstruction()), this, SLOT(lInstructionSlot()));
    connect(programView->moveMenu, SIGNAL(axisMoveInstruction_signal()), this, SLOT(axisMoveInstruction_Slot()));
    connect(programView->moveMenu, SIGNAL(arcInstruction()), this, SLOT(arcInstructionSlot()));

    //PalletMenu
    connect(programView->palletMenu, SIGNAL(palletForwartPage()), this, SLOT(palletForwardPageSlot()));
    connect(programView->palletMenu, SIGNAL(palletNextPage()), this, SLOT(palletNextPageSlot()));
    connect(programView->palletMenu, SIGNAL(palletHeadInstruction()), this, SLOT(palletHeadInstructionSlot()));
    connect(programView->palletMenu, SIGNAL(palletTailInstruction()), this, SLOT(palletTailInstructionSlot()));
    connect(programView->palletMenu, SIGNAL(approachPointInstruction()), this, SLOT(approachPointInstructionSlot()));
    connect(programView->palletMenu, SIGNAL(fleePointInstruction()), this, SLOT(fleePointInstructionSlot()));
    connect(programView->palletMenu, SIGNAL(stackPointInstruction()), this, SLOT(stackPointInstructionSlot()));

    //FlowMenu
    connect(programView->flowMenu, SIGNAL(flowForwardPage()), this, SLOT(flowForwardPageSlot()));
    connect(programView->flowMenu, SIGNAL(flowNextPage()), this, SLOT(flowNextPageSlot()));
    connect(programView->flowMenu, SIGNAL(conditionInstruction()), this, SLOT(conditionInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(selectInstruction()), this, SLOT(selectInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(jumpInstruction()), this, SLOT(jumpInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(loopInstruction()), this, SLOT(loopInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(callInstruction()), this, SLOT(callInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(labelInstruction()), this, SLOT(labelInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(pauseInstruction()), this, SLOT(pauseInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(createTaskInstruction()), this, SLOT(createTaskInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(abortInstruction()), this, SLOT(abortInstructionSlot()));
    connect(programView->flowMenu, SIGNAL(endInstruction()), this, SLOT(endInstructionSlot()));

    //RegisterMenu
    connect(programView->registerMenu, SIGNAL(registerForwardPage()), this, SLOT(registerForwardPageSlot()));
    connect(programView->registerMenu, SIGNAL(registerNextPage()), this, SLOT(registerNextPageSlot()));
    connect(programView->registerMenu, SIGNAL(rInstruction()), this, SLOT(rInstructionSlot()));
    connect(programView->registerMenu, SIGNAL(pRInstruction()), this, SLOT(pRInstructionSlot()));
    connect(programView->registerMenu, SIGNAL(pLInstruction()), this, SLOT(pLInstructionSlot()));
    connect(programView->registerMenu, SIGNAL(timerInstruction()), this, SLOT(timerInstructionSlot()));

    //IoMenu
    connect(programView->ioMenu, SIGNAL(ioForwardPage()), this, SLOT(ioForwardPageSlot()));
    connect(programView->ioMenu, SIGNAL(ioNextPage()), this, SLOT(ioNextPageSlot()));
    connect(programView->ioMenu, SIGNAL(numberInstruction()), this, SLOT(numberInstructionSlot()));
    connect(programView->ioMenu, SIGNAL(analogInstruction()), this, SLOT(analogInstructionSlot()));
    connect(programView->ioMenu, SIGNAL(systemInstruction()), this, SLOT(systemInstructionSlot()));

    //OtherMenu
    connect(programView->otherMenu1, SIGNAL(otherForwardPage()), this, SLOT(otherForwardPageSlot()));
    connect(programView->otherMenu1, SIGNAL(otherNextPage()), this, SLOT(otherNextPageSlot()));
    connect(programView->otherMenu1, SIGNAL(toolCoordinateInstruction()), this, SLOT(toolCoordinateInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(userCoordinateInstruction()), this, SLOT(userCoordinateInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(toolCompensateInstruction()), this, SLOT(toolCompensateInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(positionCompensateInstruction()), this, SLOT(positionCompensateInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(rateInstruction()), this, SLOT(rateInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(messageInstruction()), this, SLOT(messageInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(alarmInstruction()), this, SLOT(alarmInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(rsrInstruction()), this, SLOT(rsrInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(visionInstruction()), this, SLOT(visionInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(musicInstruction()), this, SLOT(musicInstructionSlot()));

    // OtherNextPageMenu
    connect(programView->otherMenu2, SIGNAL(otherForwardPage_signal()), this, SLOT(otherNextMenuForwardPageSlot()));
    connect(programView->otherMenu2, SIGNAL(otherNextPage_signal()), this, SLOT(otherNextMenuNextPageSlot()));
    connect(programView->otherMenu2, SIGNAL(addLoadMapInstruction_signal()), this, SLOT(addloadmapinstructionSlot()));
    connect(programView->otherMenu2, SIGNAL(showLaserCameraMenu_signal()), this, SLOT(showLaserCameraMenu_slot()));
    //电池电量检测指令
    connect(programView->otherMenu2, SIGNAL(addCheckBatteryInstruction_signal()), this, SLOT(addCheckBatteryInstructionSlot()));
    //等待命令
    connect(programView->otherMenu2, SIGNAL(addWaitCommandInstruction_signal()), this, SLOT(addWaitCommandInstructionSlot()));
    // 机械手控制指令
    connect(programView->otherMenu2, SIGNAL(addRobotMoveInstruction_Signal()), this, SLOT(addRobotMoveInstruction_Slot()));
    connect(programView->otherMenu1, SIGNAL(chargingInstruction()), this, SLOT(chargingInstructionSlot()));
    connect(programView->otherMenu1, SIGNAL(liftMechanismInstruction()), this, SLOT(liftMechanismInstructionSlot()));
    // 滚筒控制指令
    connect(programView->otherMenu2, SIGNAL(addRollerInstruction_Signal()), this, SLOT(addRollerInstruction_slot()));

    //StampingMenu
    connect(programView->stampMenu, SIGNAL(stampForwardPage()), this, SLOT(stampForwardPageSlot()));
    connect(programView->stampMenu, SIGNAL(stampNextPage()), this, SLOT(stampNextPageSlot()));
    connect(programView->stampMenu, SIGNAL(getInstruction()), this, SLOT(getInstructionSlot()));
    connect(programView->stampMenu, SIGNAL(getWaitInstruction()), this, SLOT(getWaitInstructionSlot()));
    connect(programView->stampMenu, SIGNAL(getAboveInstruction()), this, SLOT(getAboveInstructionSlot()));
    connect(programView->stampMenu, SIGNAL(getEndInstruction()), this, SLOT(getEndInstructionSlot()));
    connect(programView->stampMenu, SIGNAL(putInstruction()), this, SLOT(putInstructionSlot()));
    connect(programView->stampMenu, SIGNAL(putWaitInstruction()), this, SLOT(putWaitInstructionSlot()));
    connect(programView->stampMenu, SIGNAL(putAboveInstruction()), this, SLOT(putAboveInstructionSlot()));
    connect(programView->stampMenu, SIGNAL(putEndInstruction()), this, SLOT(putEndInstructionSlot()));
    //拓展新指令增加代码20191122hualei
    connect(programView->weldMenu, SIGNAL(addWeldStartInstruction_signal()), this, SLOT(addWeldStartInstruction_slot()));
    //新指令20191130 ZHUHT
    connect(programView->weldMenu, SIGNAL(addWeldEndInstruction_signal()), this, SLOT(addWeldEndInstruction_slot()));
    connect(programView->weldMenu, SIGNAL(addWeaveInstruction_signal()), this, SLOT(addWeaveInstruction_slot()));
    connect(programView->weldMenu, SIGNAL(addWeaveEndInstruction_signal()), this, SLOT(addWeaveEndInstruction_slot()));
    connect(programView->weldMenu, SIGNAL(addTrackWeldTastInstruction_signal()), this, SLOT(addTrackWeldTastInstruction_slot()));
    connect(programView->weldMenu, SIGNAL(addTrackWeldEndInstruction_signal()), this, SLOT(addTrackWeldEndInstruction_slot()));
    connect(programView->weldMenu, SIGNAL(addWatchDIInstruction_signal()), this, SLOT(addWatchDIInstruction_slot()));
    connect(programView->weldMenu, SIGNAL(showLaserCameraMenu_signal()), this, SLOT(showLaserCameraMenu_slot()));
    connect(programView->weldMenu, SIGNAL(weldForwardPage()), this, SLOT(stampForwardPageSlot()));
    connect(programView->weldStartInsView,SIGNAL(showPropertyView()),programView->weldPropertyDialog,SLOT(showView_slot()));
    connect(programView->weldStartInsView,SIGNAL(showConditionView()),programView->weldConditionDialog,SLOT(showView_slot()));
    connect(programView->weldEndInsView,SIGNAL(showPropertyView()),programView->weldPropertyDialog,SLOT(showView_slot()));
    connect(programView->weldEndInsView,SIGNAL(showConditionView()),programView->weldConditionDialog,SLOT(showView_slot()));
    connect(programView->weldPropertyDialog,SIGNAL(showErrorMsgBox(QString)),this,SLOT(showWeldPropetyViewErrorMsg(QString)));
    connect(programView->weldConditionDialog,SIGNAL(showErrorMsgBox(QString)),this,SLOT(showWeldPropetyViewErrorMsg(QString)));
    connect(programView->weldEndInsView,SIGNAL(showErrorMsgBox(QString)),this,SLOT(showWeldPropetyViewErrorMsg(QString)));
    connect(programView->weldStartInsView,SIGNAL(showErrorMsgBox(QString)),this,SLOT(showWeldPropetyViewErrorMsg(QString)));
    connect(programView->watchDIInsView,SIGNAL(showErrorMsgBox(QString)),this,SLOT(showWeldPropetyViewErrorMsg(QString)));
    connect(programView->weaveInsView,SIGNAL(showErrorMsgBox(QString)),this,SLOT(showWeldPropetyViewErrorMsg(QString)));
    connect(programView->weaveInsView,SIGNAL(showWeaveConditionView_signal()),programView->weaveConditionDialog,SLOT(showView_slot()));

    connect(programView, SIGNAL(getCurrentLineInstruction(int)), this, SLOT(getCurrentLineInstructionSlot(int)));
    connect(programView, SIGNAL(openInstructionEditView()), this, SLOT(openInstructionEditViewSlot()));
    connect(programView, SIGNAL(saveCurrentInstruction_Signal()), this, SLOT(saveCurrentinstruction_Slot()));

    //motionInstructionView
    connect(programView->motionInstructionView, SIGNAL(setDefaultJMoveSpeed_signal(double)),this, SLOT(setDefaultJMoveSpeed_slot(double)));
        connect(programView->motionInstructionView, SIGNAL(setDefaultLMoveSpeed_signal(double,QString)),this, SLOT(setDefaultLMoveSpeed_slot(double,QString)));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(finishEditInstruction()),programView->motionInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->motionInstructionView, SIGNAL(selectJInstruction()),programView->motionInstructionDelegate, SLOT(selectJInstructionSlot()));
    connect(programView->motionInstructionView, SIGNAL(selectLInstruction()),programView->motionInstructionDelegate, SLOT(selectLInstructionSlot()));
    connect(programView->motionInstructionView, SIGNAL(unlockPoint()),programView->motionInstructionDelegate, SLOT(unlockPointSlot()));
    connect(programView->motionInstructionView, SIGNAL(recordPoint_signal(int,int)),programView->motionInstructionDelegate, SLOT(recordPointSlot(int,int)));
    connect(programView->motionInstructionView, SIGNAL(moveToPointSignal(int,int)),programView->motionInstructionDelegate, SLOT(moveToPointSlot(int,int)));
    connect(programView->motionInstructionView, SIGNAL(moveToPointFinish( )),programView->motionInstructionDelegate, SLOT(moveToPointFinishSlot( )));
    connect(programView->motionInstructionView, SIGNAL(changePointToDeg(int)),programView->motionInstructionDelegate, SLOT(changePointToDegSlot(int)));
    connect(programView->motionInstructionView, SIGNAL(changePointToWorld(int)),programView->motionInstructionDelegate, SLOT(changePointToWorldSlot(int)));
    connect(programView->motionInstructionView, SIGNAL(inputPointTakeEffect( )),programView->motionInstructionDelegate, SLOT(inputPointTakeEffectSlot( )));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectDiInstruction_signal(bool)),programView->motionInstructionDelegate, SLOT(selectDiInstructionSlot(bool)));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectWjntInstruction()),programView->motionInstructionDelegate, SLOT(selectWjntInstructionSlot()));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectIncInstruction()),programView->motionInstructionDelegate, SLOT(selectIncInstructionSlot()));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectAccInstruction()),programView->motionInstructionDelegate, SLOT(selectAccInstructionSlot()));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectOffsetInstruction()),programView->motionInstructionDelegate, SLOT(selectOffsetInstructionSlot()));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectToolOffsetInstruction()),programView->motionInstructionDelegate, SLOT(selectToolOffsetInstructionSlot()));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectEvInstruction()),programView->motionInstructionDelegate, SLOT(selectEvInstructionSlot()));
    connect(programView->motionInstructionView->motionInstruction2View, SIGNAL(selectPthInstruction()),programView->motionInstructionDelegate, SLOT(selectPthInstructionSlot()));
    connect(programView->motionInstructionDelegate, SIGNAL(setIsSaveSignal(bool)),this,SLOT(setIsSaveState(bool)));

    //IfInstructionView
    connect(programView->ifInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->ifInstructionView, SIGNAL(finishEditInstruction()),programView->ifInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->ifInstructionView, SIGNAL(selectJmp()), programView->ifInstructionDelegate, SLOT(selectJmpSlot()));
    connect(programView->ifInstructionView, SIGNAL(selectCall()), programView->ifInstructionDelegate, SLOT(selectCallSlot()));
    connect(programView->ifInstructionView, SIGNAL(browseCallProgram(QString)),programView->ifInstructionDelegate, SLOT(browseCallProgramSlot(QString)));
    connect(programView->ifInstructionView, SIGNAL(cleanNote()), programView->ifInstructionDelegate, SLOT(cleanNoteSlot()));

    //LabelJmpView
    connect(programView->labelJmpView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->labelJmpView, SIGNAL(finishEditInstruction()),programView->labelJmpDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(selectLabelInstruction()),programView->labelJmpDelegate, SLOT(selectLabelInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(selectJmpInstruction()),programView->labelJmpDelegate, SLOT(selectJmpInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(selectEndInstruction()),programView->labelJmpDelegate, SLOT(selectEndInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(selectPauseInstruction()),programView->labelJmpDelegate, SLOT(selectPauseInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(selectAbortInstruction()), programView->labelJmpDelegate, SLOT(selectAbortInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(selectCallInstruction()), programView->labelJmpDelegate, SLOT(selectCallInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(selectRunInstruction()),programView->labelJmpDelegate, SLOT(selectRunInstructionSlot()));
    connect(programView->labelJmpView, SIGNAL(browseCallProgram(QString)),programView->labelJmpDelegate, SLOT(browseCallProgramSlot(QString)));

    //WaitInstructionView
    connect(programView->waitInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->waitInstructionView, SIGNAL(finishEditInstruction()),programView->waitInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->waitInstructionView, SIGNAL(selectWaitTime()),programView->waitInstructionDelegate, SLOT(selectWaitTimeSlot()));
    connect(programView->waitInstructionView, SIGNAL(selectWaitR()),programView->waitInstructionDelegate, SLOT(selectWaitRSlot()));
    connect(programView->waitInstructionView, SIGNAL(selectWaitCondition()),programView->waitInstructionDelegate, SLOT(selectWaitConditionSlot()));
    connect(programView->waitInstructionView, SIGNAL(clearNote()),programView->waitInstructionDelegate, SLOT(clearNoteSlot()));
    connect(programView->waitInstructionView, SIGNAL(isSelectTimeout()),programView->waitInstructionDelegate, SLOT(isSelectTimeoutSlot()));
    connect(programView->waitInstructionView, SIGNAL(isSelectSettingLimitTime()),programView->waitInstructionDelegate, SLOT(isSelectSettingLimitTimeSlot()));


    //ForInstructionView
    connect(programView->forInstructionView, SIGNAL(saveInstructionHead(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->forInstructionView, SIGNAL(finishEditInstruction()),programView->forInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->forInstructionView, SIGNAL(selectForHead()),programView->forInstructionDelegate, SLOT(selectForHeadSlot()));
    connect(programView->forInstructionView, SIGNAL(selectFortail()),programView->forInstructionDelegate, SLOT(selectFortailSlot()));
    connect(programView->forInstructionView, SIGNAL(selectToType()),programView->forInstructionDelegate, SLOT(selectToTypeSlot()));
    connect(programView->forInstructionView, SIGNAL(selectDownType()),programView->forInstructionDelegate, SLOT(selectDownTypeSlot()));
    connect(programView->forInstructionView, SIGNAL(clearNote()),programView->forInstructionDelegate, SLOT(clearNoteSlot()));

    //RegisterInstructionView
    connect(programView->registerInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->registerInstructionView, SIGNAL(finishEditInstruction()),programView->registerInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->registerInstructionView, SIGNAL(selectRInstruction()),programView->registerInstructionDelegate, SLOT(selectRInstructionSlot()));
    connect(programView->registerInstructionView, SIGNAL(selectGRInstruction()), programView->registerInstructionDelegate, SLOT(selectGRInstructionSlot()));
    connect(programView->registerInstructionView, SIGNAL(selectPRInstruction()),programView->registerInstructionDelegate, SLOT(selectPRInstructionSlot()));
    connect(programView->registerInstructionView, SIGNAL(selectPRijInstruction()),programView->registerInstructionDelegate, SLOT(selectPRijInstructionSlot()));
    connect(programView->registerInstructionView, SIGNAL(selectPLInstruction()),programView->registerInstructionDelegate, SLOT(selectPLInstructionSlot()));
    connect(programView->registerInstructionView, SIGNAL(clearNote()), programView->registerInstructionDelegate, SLOT(clearNoteSlot()));

    //SelectInstructionView
    connect(programView->selectInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->selectInstructionView, SIGNAL(finishEditInstruction()),programView->selectInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->selectInstructionView, SIGNAL(selectJmpDeal()),programView->selectInstructionDelegate, SLOT(selectJmpDealSlot()));
    connect(programView->selectInstructionView, SIGNAL(selectCallDeal()),programView->selectInstructionDelegate, SLOT(selectCallDealSlot()));
    connect(programView->selectInstructionView, SIGNAL(browseCallProgram(QString)),programView->selectInstructionDelegate, SLOT(browseCallProgramSlot(QString)));
    connect(programView->selectInstructionView, SIGNAL(clearNote()), programView->selectInstructionDelegate, SLOT(clearNoteSlot()));

    //SkipConditionView
    connect(programView->skipConditionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->skipConditionView, SIGNAL(finishEditInstruction()),programView->skipConditionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->skipConditionView, SIGNAL(selectConditionHead()),programView->skipConditionDelegate, SLOT(selectConditionHeadSlot()));
    connect(programView->skipConditionView, SIGNAL(selectConditionTail()),programView->skipConditionDelegate, SLOT(selectConditionTailSlot()));
    connect(programView->skipConditionView, SIGNAL(clearNote()),programView->skipConditionDelegate, SLOT(clearNoteSlot()));

    //OutputInstructionView
    connect(programView->outputInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->outputInstructionView, SIGNAL(finishEditInstruction()), programView->outputInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->outputInstructionView, SIGNAL(selectSwitch()),programView->outputInstructionDelegate, SLOT(selectSwitchSlot()));
    connect(programView->outputInstructionView, SIGNAL(selectPulse()),programView->outputInstructionDelegate, SLOT(selectPulseSlot()));
    connect(programView->outputInstructionView, SIGNAL(selectRegister()),programView->outputInstructionDelegate, SLOT(selectRegisterSlot()));
    connect(programView->outputInstructionView, SIGNAL(clearNote()),programView->outputInstructionDelegate, SLOT(clearNoteSlot()));
    connect(programView->outputInstructionView, SIGNAL(selectDOInstruction()),programView->outputInstructionDelegate, SLOT(selectDOInstructionSlot()));
    connect(programView->outputInstructionView, SIGNAL(selectAOInstruction()),programView->outputInstructionDelegate, SLOT(selectAOInstructionSlot()));

    //CoordinateInstructionView
    connect(programView->coordinateInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->coordinateInstructionView, SIGNAL(finishEditInstruction()),programView->coordinateInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->coordinateInstructionView, SIGNAL(selectSetToolInstruction()), programView->coordinateInstructionDelegate, SLOT(selectSetToolInstructionSlot()));
    connect(programView->coordinateInstructionView, SIGNAL(selectSetFrameInstruction()),programView->coordinateInstructionDelegate, SLOT(selectSetFrameInstructionSlot()));
    connect(programView->coordinateInstructionView, SIGNAL(selectToolNumInstruction()),programView->coordinateInstructionDelegate, SLOT(selectToolNumInstructionSlot()));
    connect(programView->coordinateInstructionView, SIGNAL(selectFrameNumInstruction()),programView->coordinateInstructionDelegate, SLOT(selectFrameNumInstructionSlot()));
    connect(programView->coordinateInstructionView, SIGNAL(clearNote()),programView->coordinateInstructionDelegate, SLOT(clearNoteSlot()));

    //OtherInstructionView
    connect(programView->otherInstructionView->otherInstruction2View, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->otherInstructionView->otherInstruction2View, SIGNAL(finishEditInstruction()),programView->otherInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->otherInstructionView, SIGNAL(selectTimerInstruction()),programView->otherInstructionDelegate, SLOT(selectTimerInstructionSlot()));
    connect(programView->otherInstructionView, SIGNAL(selectTimerInstruction2()),programView->otherInstructionDelegate, SLOT(selectTimerInstructionSLot2()));
    connect(programView->otherInstructionView->otherInstruction2View, SIGNAL(selectJMaxSpeedInstruction()),programView->otherInstructionDelegate, SLOT(selectJMaxSpeedInstructionSlot()));
    connect(programView->otherInstructionView->otherInstruction2View, SIGNAL(selectLMaxSpeedInstruction()),programView->otherInstructionDelegate, SLOT(selectLMaxSpeedInstructionSlot()));
    connect(programView->otherInstructionView->otherInstruction2View, SIGNAL(clearNote()),programView->otherInstructionDelegate, SLOT(clearNoteSlot()));

    //PalletInstrucionView
    connect(programView->palletInstructionView, SIGNAL(finishHeadInstruction()),programView->palletInstructionDelegate, SLOT(finishHeadInstructionSlot()));
    connect(programView->palletInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));

    //PalletMotionInstructionView
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(finishMotionInstruction()),programView->palletInstructionDelegate, SLOT(finishMotionInstructionSlot()));
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(selectJInstruction()),programView->palletInstructionDelegate, SLOT(selectJInstructionSlot()));
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(selectLInstruction()),programView->palletInstructionDelegate, SLOT(selectLInstructionSlot()));
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(moveToPointSignal(int,int)),programView->palletInstructionDelegate, SLOT(moveToPointSlot(int,int)));
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(moveToPointFinish()),programView->palletInstructionDelegate, SLOT(moveToPointFinishSlot()));
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(selectSkipInstruction()),programView->palletInstructionDelegate, SLOT(selectSkipInstructionSlot()));
    connect(programView->palletInstructionView->palletMotionInstructionView, SIGNAL(clearNote()),programView->palletInstructionDelegate, SLOT(clearNoteSlot()));

    connect(programView->palletInstructionDelegate, SIGNAL(setIsSaveSignal(bool)),this,SLOT(setIsSaveState(bool)));

    //vision
    connect(programView->visionInstructionView, SIGNAL(saveInstruction(QString)),this, SLOT(saveInstructionSlot(QString)));

    // MOVE_MAG磁导航-MoveMagInstructionView
    connect(programView->moveMagInstructionView, SIGNAL(saveInstruction(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->moveMagInstructionView, SIGNAL(finishEditInstruction()),programView->moveMagInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->moveMagInstructionView, SIGNAL(cleanNote()), programView->moveMagInstructionDelegate, SLOT(clearNoteSlot()));

    // MOVE_FREE自由导航
    connect(programView->moveFreeInstructionView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->moveFreeInstructionView, SIGNAL(finishEditInstructionSignal()), programView->moveFreeInstructionDelegate, SLOT(finishEditInstruction_Slot()));
    connect(programView->moveFreeInstructionView, SIGNAL(clearNoteSignal()), programView->moveFreeInstructionDelegate, SLOT(clearNote()));
    connect(programView->moveFreeInstructionView, SIGNAL(recordDPointSignal(int)), programView->moveFreeInstructionDelegate, SLOT(recordDPointSlot(int)));
    connect(programView->moveFreeInstructionView, SIGNAL(moveToDPointSignal(int)), programView->moveFreeInstructionDelegate, SLOT(moveToDPointSlot(int)));
    connect(programView->moveFreeInstructionView->moveFreeDPointView, SIGNAL(recordEditedDPointSignal(int)), programView->moveFreeInstructionDelegate, SLOT(recordDPointSlot(int)));
    connect(programView->moveFreeInstructionDelegate, SIGNAL(setIsSaveSignal(bool)), this, SLOT(setIsSaveState(bool)));
    connect(programView->moveFreeInstructionView->moveFreeVmarkSettingView,SIGNAL(finishedEditInstruction()),\
                programView->moveFreeInstructionView,SLOT(finishedEditInstruction_slot()));

    // MODBUS_START
    connect(programView->modbusStartInstructionView, SIGNAL(finishEidtInstruction()), programView->modbusStartInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->modbusStartInstructionView, SIGNAL(cleanNote()), programView->modbusStartInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->modbusStartInstructionView, SIGNAL(saveInstruction(QString)), this, SLOT(saveInstructionSlot(QString)));

    // MODBUS_READ
    connect(programView->modbusReadInstructionView, SIGNAL(finishEditInstruction()), programView->modbusReadInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->modbusReadInstructionView, SIGNAL(cleanNote()), programView->modbusReadInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->modbusReadInstructionView, SIGNAL(saveInstruction(QString)), this, SLOT(saveInstructionSlot(QString)));

    // MODBUS_WRITE
    connect(programView->modbusWriteInstructionView, SIGNAL(finishEditInstruction()), programView->modbusWriteInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->modbusWriteInstructionView, SIGNAL(cleanNoteSignal()), programView->modbusWriteInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->modbusWriteInstructionView, SIGNAL(saveInstruction(QString)), this, SLOT(saveInstructionSlot(QString)));

    // SET_ODOM
    connect(programView->odometryInstructionView, SIGNAL(finishEditInstruction()), programView->odometryInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->odometryInstructionView, SIGNAL(cleanNoteSignal()), programView->odometryInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->odometryInstructionView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));

    // TCP_START
    connect(programView->tcpStartInstructionView, SIGNAL(finishEditInstructionSignal()), programView->tcpStartInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->tcpStartInstructionView, SIGNAL(cleanNoteSignal()), programView->tcpStartInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->tcpStartInstructionView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));

    // TCP_READ
    connect(programView->tcpReadInstructionView, SIGNAL(finishEditInstructionSignal()), programView->tcpReadInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->tcpReadInstructionView, SIGNAL(cleanNoteStrSignal()), programView->tcpReadInstructionDelegate, SLOT(cleanNoteStrSlot()));
    connect(programView->tcpReadInstructionView, SIGNAL(saveInstruction(QString)), this, SLOT(saveInstructionSlot(QString)));

    // TCP_WRITE
    connect(programView->tcpWriteInstructionView, SIGNAL(finishEditInstructionSignal()), programView->tcpWriteInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->tcpWriteInstructionView, SIGNAL(cleanNoteSignal()), programView->tcpWriteInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->tcpWriteInstructionView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));

    // FTP 上传编辑好的程序文件后控制器再加载文件信号
    connect(ftpManage, SIGNAL(isPutFile(bool,QString)), this, SLOT(ftpFinishedPutFile(bool,QString)));
    connect(ftpManage, SIGNAL(getFileInServerDirectory(QHash<QString,bool>,QString,QString)), \
            programView->musicInstructionView, SLOT(listMusicDirSlot(QHash<QString,bool>,QString,QString)));
    connect(ftpManage, SIGNAL(getFileInServerDirectory(QHash<QString,bool>,QString,QString)),\
            programView->loadMapInstructionView, SLOT(listMapFileDirSlot(QHash<QString,bool>,QString,QString)));

    // MUSIC
    connect(programView->musicInstructionView, SIGNAL(finishEditInstructionSignal()), programView->musicInstructionDelegate, SLOT(finishedEditInstructionSlot()));
    connect(programView->musicInstructionView, SIGNAL(cleanNote()), programView->musicInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->musicInstructionView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));

    // CHARGING
    connect(programView->chargingInstructionView, SIGNAL(cleanNoteStrSignal()), programView->chargingInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->chargingInstructionView, SIGNAL(finishEditInstruction()), programView->chargingInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->chargingInstructionView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));

    // LIFT
    connect(programView->liftMechanismInstructionView, SIGNAL(cleanNoteSignal()), programView->liftMechanismInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->liftMechanismInstructionView, SIGNAL(finishEditInstructionSignal()), programView->liftMechanismInstructionDelegate, SLOT(finishedEditInstructionSlot()));
    connect(programView->liftMechanismInstructionView, SIGNAL(saveInstruction(QString)), this, SLOT(saveInstructionSlot(QString)));

    // ROLLER
    connect(programView->rollerInstructionView, SIGNAL(cleanNoteSignal()), programView->rollerInstructionDelegate, SLOT(cleanNoteSlot()));
    connect(programView->rollerInstructionView, SIGNAL(finishEditInstructionSignal()), programView->rollerInstructionDelegate, SLOT(finishedEditInstructionSlot()));
    connect(programView->rollerInstructionView, SIGNAL(saveInstruction(QString)), this, SLOT(saveInstructionSlot(QString)));

    // LOAD_MAP
    connect(programView->loadMapInstructionView, SIGNAL(cleanNote_signal()), programView->loadMapInstructionDelegate, SLOT(cleanNote_slot()));
    connect(programView->loadMapInstructionView, SIGNAL(finishedEditInstruction_signal()), programView->loadMapInstructionDelegate, SLOT(finishededitinstructionSlot()));
    connect(programView->loadMapInstructionView, SIGNAL(saveInstruction_signal(QString)), this, SLOT(saveInstructionSlot(QString)));

    //电量检测
    connect(programView->checkBatteryView, SIGNAL(finishEditInstructionSignal()), programView->checkBatteryDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->checkBatteryView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    //等待命令
    connect(programView->waitCommandView, SIGNAL(finishEditInstructionSignal()), programView->waitCommandDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->waitCommandView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));

    // 机械手控制指令
    connect(programView->robotMoveInstructionView, SIGNAL(cleanNote_Signal()), programView->robotMoveInstructionDelegate, SLOT(cleanNote_Slot()));
    connect(programView->robotMoveInstructionView, SIGNAL(instructionEditFinished_Signal()), programView->robotMoveInstructionDelegate, SLOT(instructionEditFinished_Slot()));
    connect(programView->robotMoveInstructionView, SIGNAL(saveInstruction_Signal(QString)), this, SLOT(saveInstructionSlot(QString)));

    //axisMove
    connect(programView->axisMoveInstructionView, SIGNAL(setCoupleControl_signal(int ,bool )), this, SLOT(setCoupleControl_slot(int ,bool )));
    connect(programView->axisMoveInstructionView, SIGNAL(finishEditInstructionSignal()), programView->axisMoveInstructionDelegate, SLOT(finishEditInstructionSlot()));
    connect(programView->axisMoveInstructionView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    //拓展新指令增加代码20191122hualei
    connect(programView->weldStartInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    //新指令20191130 ZHUHT
    connect(programView->weldEndInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->weaveInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->weaveEndInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->trackWeldTASTInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->trackWeldEndInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->watchDIInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->lasercameraControlInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->lasercameraTrackInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->lasercameraFetchPointInsView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));
    connect(programView->bufferMoveView, SIGNAL(saveInstructionSignal(QString)), this, SLOT(saveInstructionSlot(QString)));

    connect(this, SIGNAL(saveMoveFreeInstruction_Signal()), programView->moveFreeInstructionView, SLOT(finishedEditInstruction_slot()));
    connect(this, SIGNAL(saveMotionInstruction_Signal()), programView->motionInstructionView->motionInstruction2View, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveIfInstruction_Signal()), programView->ifInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveLblJmpInstruction_Signal()), programView->labelJmpView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveWaitInstruction_Signal()), programView->waitInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveForInstruction_Signal()), programView->forInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveRegisterInstruction_Signal()), programView->registerInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveSelectInstruction_Signal()), programView->selectInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveSkipInstruction_Signal()), programView->skipConditionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveOutputInstruction_Signal()), programView->outputInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveCoordinateInstruction_Signal()), programView->coordinateInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveOtherInstruction_Signal()), programView->otherInstructionView->otherInstruction2View, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(savePalletInstruction_Signal()), programView->palletInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(savePalletMotionInstruction_Signal()), programView->palletInstructionView->palletMotionInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveVisionInstruction_Signal()), programView->visionInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveMoveMagInstruction_Signal()), programView->moveMagInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveModbusStartInstruction_Signal()), programView->modbusStartInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveModbusReadInstruction_Signal()), programView->modbusReadInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveModbusWriteInstruction_Signal()), programView->modbusWriteInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveSetOdomInstruction_Signal()), programView->odometryInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveTcpStartInstruction_Signal()), programView->tcpStartInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveTcpReadInstruction_Signal()), programView->tcpReadInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveTcpWriteInstruction_Signal()), programView->tcpWriteInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveChargingInstruction_Signal()), programView->chargingInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveMusicInstruction_Signal()), programView->musicInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveLiftInstruction_Signal()), programView->liftMechanismInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveLoadMapInstruction_Signal()), programView->loadMapInstructionView, SLOT(on_save_Btn_clicked()));

    connect(this, SIGNAL(saveCheckBatteryInstruction_Signal()), programView->checkBatteryView, SLOT(finishedEditInstruction_slot()));
    connect(this, SIGNAL(saveWaitCommandInstruction_Signal()), programView->waitCommandView, SLOT(finishedEditInstruction_slot()));
    connect(this, SIGNAL(saveRobotMoveInstruction_Signal()), programView->robotMoveInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveRollerInstruction_Signal()), programView->rollerInstructionView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveAxisMoveInstruction_Signal()), programView->axisMoveInstructionView, SLOT(on_save_Btn_clicked()));
    //拓展新指令增加代码20191122hualei
    connect(this, SIGNAL(saveWeldStartInsTruction_signal()), programView->weldStartInsView, SLOT(on_save_Btn_clicked()));

    //新指令20191130 ZHUHT
    connect(this, SIGNAL(saveWeldEndInsTruction_signal()), programView->weldEndInsView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveWeaveInsTruction_signal()), programView->weaveInsView, SLOT(on_save_Btn_clicked()));
//    connect(this, SIGNAL(saveWeaveEndInsTruction_signal()), programView->weaveEndInsView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveTrackWeldTastInstruction_signal()), programView->trackWeldTASTInsView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveTrackWeldEndInstruction_signal()), programView->trackWeldEndInsView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveWatchDIInstruction_signal()), programView->watchDIInsView, SLOT(on_save_Btn_clicked()));

    connect(this, SIGNAL(saveLaserCameraControlIns_signal()), programView->lasercameraControlInsView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveLaserCameraTrackIns_signal()), programView->lasercameraTrackInsView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveLaserCameraFetchPointIns_signal()), programView->lasercameraFetchPointInsView, SLOT(on_save_Btn_clicked()));
    connect(this, SIGNAL(saveBufferMoveIns_signal()), programView->bufferMoveView, SLOT(on_save_Btn_clicked()));

    //laserCamera
    connect(programView->laserCameraMenu, SIGNAL(forwardPage_signal()), this, SLOT(laserCameraMenuForwardPage_slot()));
    connect(programView->laserCameraMenu, SIGNAL(addCameraLaserControlIns_signal()), this,
                                            SLOT(addLaserCameraControlIns_slot()));
    connect(programView->laserCameraMenu, SIGNAL(addCameraLaserTrackIns_signal()), this,
                                            SLOT(addLaserCameraTrackIns_slot()));
    connect(programView->laserCameraMenu, SIGNAL(addCameraLaserFetchPointIns_signal()), this,
                                            SLOT(addLaserCameraFetchPointIns_slot()));
    connect(programView->laserCameraMenu, SIGNAL(addLaserScan_signal()), this,
                                            SLOT(addLaserScan_slot()));
    connect(programView->laserCameraMenu, SIGNAL(addLaserScanEnd_signal()), this,
                                            SLOT(addLaserScanEnd_slot()));
    connect(programView->laserCameraMenu, SIGNAL(addBufferMove_signal()), this,
                                            SLOT(addBufferMove_slot()));

}

void ProgramDelegate::initialConnectButtonFunc()
{
    connect(programView->buttonFunMap, SIGNAL(jInstruction()), this, SLOT(jInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(lInstruction()), this, SLOT(lInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(arcInstruction()), this, SLOT(arcInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(labelInstruction()), this, SLOT(labelInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(jumpInstruction()), this, SLOT(jumpInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(conditionInstruction()), this, SLOT(conditionInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(waitInstruction()), this, SLOT(waitInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(numberInstruction()), this, SLOT(numberInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(analogInstruction()), this, SLOT(analogInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(moveMagInstruction()), this, SLOT(guidanceMoveMagSlot()));
    connect(programView->buttonFunMap, SIGNAL(moveFreeInstruction()), this, SLOT(guidanceMoveFreeSlot()));
    connect(programView->buttonFunMap, SIGNAL(setOdometryInstruction()), this, SLOT(setOdomResetSlot()));
    connect(programView->buttonFunMap, SIGNAL(addRollerInstruction_Signal()), this, SLOT(addRollerInstruction_slot()));
    connect(programView->buttonFunMap, SIGNAL(addLoadMapInstruction_signal()), this, SLOT(addloadmapinstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(addCheckBatteryInstruction_signal()), this, SLOT(addCheckBatteryInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(addWaitCommandInstruction_signal()), this, SLOT(addWaitCommandInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(addRobotMoveInstruction_Signal()), this, SLOT(addRobotMoveInstruction_Slot()));
    connect(programView->buttonFunMap, SIGNAL(chargingInstruction()), this, SLOT(chargingInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(liftMechanismInstruction()), this, SLOT(liftMechanismInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(musicInstruction()), this, SLOT(musicInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(axisMoveInstruction_signal()), this, SLOT(axisMoveInstruction_Slot()));


    connect(programView->buttonFunMap, SIGNAL(rInstruction()), this, SLOT(rInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(pRInstruction()), this, SLOT(pRInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(pLInstruction()), this, SLOT(pLInstructionSlot()));
    connect(programView->buttonFunMap, SIGNAL(timerInstruction()), this, SLOT(timerInstructionSlot()));

}

void ProgramDelegate::initialView()
{
    programView->fileInformation = currentProgram;
    programView->fileName = "";
    programView->currentLineIndex = 2;
    programView->currentLineInstruction = "";
    programView->menuViewShowFlag = 1;
    programView->isProgramFileSaved = true;
    programView->instructionListFlag = 0;

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_USUALY1;
    programView->menuBtnTitle = tr("常用指令");
    programView->hideOrShowBtnPicture = "/agvwork/AgvHmi/baseBag/hmiProject/resources/programsources/page/program_next_n.png";
    programView->editInstructionBtnPicture1 = "color: rgb(255, 255, 255);border-width:0px;border-style:outset;image: url(/agvwork/AgvHmi/baseBag/hmiProject/resources/programsources/basic/program_base_n.png);";
    programView->editInstructionBtnPicture2 = "color: rgb(255, 255, 255);border-width:0px;border-style:outset;image: url(/agvwork/AgvHmi/baseBag/hmiProject/resources/programsources/basic/program_base_p.png);";

    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_END;

    programView->updateView(true,true);

}

void ProgramDelegate::initialMusicFileListStart(int result,QString note)
{
    //music file list
//    std::vector<std::string> tmpFileList;
//    communicateNormalDelegate->getFileList(2,tmpFileList);//有时候会导致ｇsoap卡这里。
//    programView->musicInstructionDelegate->setMusicFileList_std(tmpFileList);

}

void ProgramDelegate::setMusicFileList(std::vector<std::string> musicFileListIn)
{
    programView->musicInstructionDelegate->setMusicFileList_std(musicFileListIn);
}

void ProgramDelegate::hideAllInstructionView()
{

    //参考 : on_InstructionListBtn_clicked()//点击 指令主界面按钮
    programView->instructionListFlag = 0;
    programView->editInstructionViewShowOrHide();   //隐藏所有属性页面

    programView->pointViewDialog->hide();           //隐藏点数据页面
}

void ProgramDelegate::openFileEditSlot()
{
    //每次打开一个文件,编辑
    programView->isProgramFileSaved = true;//刚打开了一个文件

    //隐藏窗口
    hideAllInstructionView();
    //qDebug()<<__LINE__<<__FUNCTION__;
    //更新数据
    //if(globalData)
    {
        currentProgram.clear();                 //英文指令
        programView->fileInformation.clear();   //显示指令
        fileData.cmdStrWriteList.clear();    //读取文件的指令
        if(!fileData.cmdStrList.isEmpty())
        {
            currentProgram << fileData.cmdStrList;       //获取
            fileData.cmdStrWriteList << currentProgram;  //写操作 缓存
        }
        //界面显示缓存
        programView->fileInformation << currentProgram;
//        for(int i =  0;i<currentProgram.size();i++)
//        {

//        }

        programView->fileName = QString::fromStdString(fileData.fileProInfo.fileName);
        programView->currentLineIndex = 0;
        programView->currentLineInstruction = "";
        programView->menuViewShowFlag = 1;
        programView->isProgramFileSaved = true;
        programView->instructionListFlag = 0;

        instructionListViewFlag = 0;//设置标志位 常用指令
        programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_USUALY1;
        programView->menuBtnTitle = tr("常用指令");

        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_END;

        //P点下标根据文件读取的点数据长度决定(2020.12.30 待定 2017.1.12修改回从1开始)
        //P 根据当前界面使用的最大编号 为 初始值 2017.2.22 改
        //maxUsedPointIndex = fileData.getPointProList.size();
        maxUsedPointIndex = 0;
        int tmpMax = 0;
        for(int i =0;i<currentProgram.size();i++)
        {
            tmpMax = programCheck.getArmPointIndex(currentProgram[i]);
            if(tmpMax > maxUsedPointIndex)
            {
                maxUsedPointIndex = tmpMax;
            }
        }
        maxUsedPointIndex++;
    }
    //更新界面
    //qDebug()<<__LINE__<<__FUNCTION__;
    programView->updateView(true,true);
    programView->initialButtonText();
}

void ProgramDelegate::moveUpInstructionSlot(int currentLineIndex)
{
    if(currentLineIndex>0)
    {
        QString tmp = currentProgram[currentLineIndex-1];
        currentProgram[currentLineIndex-1] = currentProgram[currentLineIndex];
        currentProgram[currentLineIndex] = tmp;

        programView->fileInformation = currentProgram;
        programView->currentLineIndex --;
//        programView->currentLineIndex --;//补充(因为update中会++)
        programView->updateView(true,true);
    }
    //qDebug() << currentLineIndex << "move up";
}

void ProgramDelegate::moveDownInstructionSlot(int currentLineIndex)
{
    if(currentLineIndex != currentProgram.size()-1)//不是最后一个
    {
        QString tmp = currentProgram[currentLineIndex+1];
        currentProgram[currentLineIndex+1] = currentProgram[currentLineIndex];
        currentProgram[currentLineIndex] = tmp;

        programView->fileInformation = currentProgram;
        programView->currentLineIndex ++;
        programView->updateView(true,true);
    }

    //qDebug() << currentLineIndex << "move down";
}

void ProgramDelegate::deleteInstructionSlot(int currentLineIndex)
{
    currentProgram.removeAt(currentLineIndex);
    //currentProgramChinese.removeAt(currentLineIndex);
    programView->fileInformation = currentProgram;
    programView->updateView(true,false);
    //qDebug() << currentLineIndex << "delete";
}

void ProgramDelegate::noteInstructionSlot(int currentLineIndex)
{
    if(currentLineIndex < currentProgram.size() && currentLineIndex>=0)
    {
        QString tmp = currentProgram[currentLineIndex];
        if(tmp.left(2).compare("//") == 0)
        {
            currentProgram[currentLineIndex] = tmp.right(tmp.size()-2);
            programView->fileInformation = currentProgram;
            programView->updateView(true,false);
            //qDebug() << currentLineIndex << "note";
        }
        else
        {
            currentProgram[currentLineIndex] = "//" + tmp;
            programView->fileInformation = currentProgram;
            programView->updateView(true,false);
            //qDebug() << currentLineIndex << "note";
        }
    }
}

void ProgramDelegate::showWeldPropetyViewErrorMsg(QString msg){
     emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),msg);
}

int ProgramDelegate::recordPointSlot(int currentLineIndex)
{
    qDebug()<<"ProgramDelegate::recordPointSlot 机器人点";
    if(globalData)
    {
        PointPro currentPositionJointOut;
        globalData->getCurrentArmPosition_joint(currentPositionJointOut);
        PointPro currentPositionDecartOut;
        globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
        std::vector<PointPro > pointregisterOut;
        ioData->getPointRegister(pointregisterOut);
        if(fileData.currentFileName != "")
        {
            if(currentProgram.size() == 0)
            {
                emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前文件没有点数据指令"));
                return 0;
            }
            //qDebug() << currentLineIndex << "record point";

            QString tmp = currentProgram[currentLineIndex];
            //qDebug() << tmp;

            //判断有无P[]
            QString pattern("(.*)\\s+(P|PR)\\[(R\\[\\d+\\]|\\d+)\\]\\s*(.*)");
            QRegExp rx(pattern);
            int pos = tmp.indexOf(rx);
            if ( pos >= 0 )
            {
                //qDebug() << "point number :" << rx.cap(2);
                int pointNumber = programView->motionInstructionView->getRrgToIndex(rx.cap(3));
                if(pointNumber <= 0)
                {
                    emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("无法载入该点数据\n请修改P点编号"));
                    return 0;
                }

                if((pointNumber-1) < fileData.normalPointLock.size())
                {
                    if(fileData.normalPointLock[pointNumber-1])
                    {
                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("该点已被锁定,无法载入"));
                        return 0;
                    }
                }

                //获取当前点数据(判断当前是关节坐标还是世界坐标)
//                if(globalData->tryLock(TRYLOCKTIME))
//                {
                    if(globalData->globalCurrentState == ENUM_COMMAND_RUN || globalData->globalCurrentState == ENUM_COMMAND_CEASE )
                    {
                        qDebug()<<"globalData->globalCurrentState = "<<globalData->globalCurrentState;
//                        globalData->unlock();
                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("机器程序正在运行中！\n请点击停止按钮后再载入点"));
                        return 0 ;
                    }

                    if(globalData->getUserInfo().account < EM_ACCOUNT_ADMIN)
                    {
//                        globalData->unlock();
                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("您当前用户没有操作权限\n请切换用户角色"));
                        return 0;
                    }

                    fileData.globalDefaultUserNum = globalData->globalDefaultUserNum;
                    fileData.globalDefaultToolNum = globalData->globalDefaultToolNum;
                    PointPro tmpPoint;
                    if(globalData->globalCoordinate == EM_JOG_COORDINATE_JOINT)
                    {
                        tmpPoint.jointFlag = EM_CF_DEG_TYPE;
                        tmpPoint.pointNum = pointNumber;
                        tmpPoint.groupNum = 0;//?
                        tmpPoint.ufValue = globalData->globalDefaultUserNum;
                        tmpPoint.utValue = globalData->globalDefaultToolNum;
                        tmpPoint.recordStatus = 0;
                        //多圈 目前空
                        tmpPoint.configString = "";
                        tmpPoint.configString = "";
                        for(int i = 0;i < currentPositionJointOut.positionValue.size();i++)
                        {
                            tmpPoint.positionValue.push_back(currentPositionJointOut.positionValue[i]);//float
                            tmpPoint.positionValue[i] = QString::number(tmpPoint.positionValue[i],'f',3).toFloat();
                        }
                        for(int i = 0;i < currentPositionJointOut.extPositionValue.size();i++)
                        {
                            tmpPoint.extPositionValue.push_back(currentPositionJointOut.extPositionValue[i]);//float
                            tmpPoint.extPositionValue[i] = QString::number(tmpPoint.extPositionValue[i],'f',3).toFloat();
                        }
                    }
                    else
                    {
                        tmpPoint.jointFlag = EM_CF_WORLD_TYPE;//globalData->globalCoordinate;
                        tmpPoint.pointNum = pointNumber;
                        tmpPoint.groupNum = 0;
                        tmpPoint.ufValue = globalData->globalDefaultUserNum;
                        tmpPoint.utValue = globalData->globalDefaultToolNum;
                        tmpPoint.recordStatus = 0;
                        //多圈
                        tmpPoint.configString = currentPositionDecartOut.configString;
                        tmpPoint.configInt = currentPositionDecartOut.configInt;
                        for(int i = 0;i < currentPositionDecartOut.positionValue.size();i++)
                        {
                            tmpPoint.positionValue.push_back(currentPositionDecartOut.positionValue[i]);//float
                            tmpPoint.positionValue[i] = QString::number(tmpPoint.positionValue[i],'f',3).toFloat();
                        }
                        for(int i = 0;i < currentPositionJointOut.extPositionValue.size();i++)
                        {
                            tmpPoint.extPositionValue.push_back(currentPositionJointOut.extPositionValue[i]);//float
                            tmpPoint.extPositionValue[i] = QString::number(tmpPoint.extPositionValue[i],'f',3).toFloat();
                        }
                    }

//                    globalData->unlock();

                    if(rx.cap(2) == "P")
                    {
                        //qDebug()<<tmpPoint.positionValue.size();
                        if(fileData.getPointProList.size() == 0)
                        {
                            fileData.getPointProList.append(tmpPoint);
                        }
                        else
                        {
                            //新判定 方法 支持动态增加多点
                            //假设 当前有10个 添加 第15个点
                            //下标0-9  实际编号1-10
                            if(pointNumber > fileData.getPointProList.size())
                            {
                                int appendCount = pointNumber - fileData.getPointProList.size();//15-10=5
                                int tmpPointNum = fileData.getPointProList.size();
                                for(int appendNum = 0;appendNum<appendCount;appendNum++)
                                {
                                    tmpPointNum++;//11-15
                                    tmpPoint.pointNum = tmpPointNum;
                                    fileData.getPointProList.append(tmpPoint);//不断加
                                }
                            }
                            else
                            {
                                //pointNumber-1 为数组下标
                                fileData.getPointProList.replace(pointNumber-1,tmpPoint);
                            }
                        }

                        bool askForSave = true;
                        //hualei ,载入点的时间过长，注释语法检查。 record point
//                        for(int i = 0;i<programView->fileInformation.size();i++)
//                        {
//                            if(programCheck.patExect(programView->fileInformation[i] , i) == ERR)
//                            {
//                                //programView->messageBoxShow(tr("提示"),tr("程序语法存在错误,请修改后再保存"));
//                                emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("程序第")+QString::number(i+1)+tr("行语法存在错误,请修改后再保存"));
//                                askForSave = false;
//                                break;
//                            }
//                        }

                        if(askForSave)
                        {
                            //2017.04.22修改 只有保存文件时候才写文件
//                            fileData.cmdStrWriteList.clear();
//                            fileData.cmdStrWriteList << programView->fileInformation;
//                            fileData.writeProgramFile(fileData.currentFileName,true);

//                            //标志位更新 用于runview重刷 缓存cmdlist
//                            //fileData.cmdStrWriteSuccess = true;
//                            //fileData.cmdStrList.clear();
//                            //fileData.cmdStrList << fileData.cmdStrWriteList;

//                            QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
//                            emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);//通知更新

                            programView->isProgramFileSaved = false;//未保存
                            QString msgInfo="载入P[";
                            msgInfo+=QString::number(pointNumber)+"]点成功";
                            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),msgInfo);
//                            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("载入P点成功"));
                        }
                    }
                    else if(rx.cap(2) == "PR")
                    {
//                        ioData->lock();
                        if(pointNumber > 0 && pointNumber <= pointregisterOut.size())
                        {
                            emit setPrSignal(pointNumber-1,tmpPoint);
                            QString msgInfo="载入PR[";
                            msgInfo+=QString::number(pointNumber)+"]点成功";
                            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),msgInfo);
//                            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("载入PR点成功"));
                            //ioData->pointRegister[pointNumber-1] = tmpPoint;
                        }
//                        ioData->unlock();
                    }
                    else
                    {
                        return 0;
                    }
//                }

            }
            else
            {
                //programView->messageBoxShow(tr("提示"),tr("当前选择语句无法载入点数据"));
                emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前选择语句无法载入点数据"));
            }

        }
        else
        {
            //programView->messageBoxShow(tr("提示"),tr("当前没有打开任何文件"));
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前没有打开任何文件,无法保存"));
        }
    }
}

void ProgramDelegate::recordPointSlotByPointNum(int pointNumber)
{
    qDebug()<<"ProgramDelegate::recordPointSlotByPointNum 机器人点";
    if(globalData)
    {
        PointPro currentPositionJointOut;
        globalData->getCurrentArmPosition_joint(currentPositionJointOut);
        PointPro currentPositionDecartOut;
        globalData->getCurrentArmPosition_decart(currentPositionDecartOut);

        if(fileData.currentFileName != "")
        {
            //获取当前点数据(判断当前是关节坐标还是世界坐标)
//            if(globalData->tryLock(TRYLOCKTIME))
//            {
                if(globalData->globalCurrentState == ENUM_COMMAND_RUN || globalData->globalCurrentState == ENUM_COMMAND_CEASE )
                {
                    qDebug()<<"globalData->globalCurrentState = "<<globalData->globalCurrentState;
//                    globalData->unlock();
                    emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("机器程序正在运行中！！\n请点击停止按钮后再载入点！"));
                    return;//return 0 ;
                }

                if(globalData->getUserInfo().account < EM_ACCOUNT_ADMIN)
                {
//                    globalData->unlock();
                    emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("您当前用户没有操作权限\n请切换用户角色"));
                    return;//return 0;
                }

                fileData.globalDefaultUserNum = globalData->globalDefaultUserNum;
                fileData.globalDefaultToolNum = globalData->globalDefaultToolNum;
                PointPro tmpPoint;
                if(globalData->globalCoordinate == EM_JOG_COORDINATE_JOINT)
                {
                    tmpPoint.jointFlag = EM_CF_DEG_TYPE;
                    tmpPoint.pointNum = pointNumber;
                    tmpPoint.groupNum = 0;
                    tmpPoint.ufValue = globalData->globalDefaultUserNum;
                    tmpPoint.utValue = globalData->globalDefaultToolNum;
                    tmpPoint.recordStatus = 0;
                    //多圈 目前空
                    tmpPoint.configString = "";
                    for(int i = 0;i < currentPositionJointOut.positionValue.size();i++)
                    {
                        tmpPoint.positionValue.push_back(currentPositionJointOut.positionValue[i]);//float
                        tmpPoint.positionValue[i] = QString::number(tmpPoint.positionValue[i],'f',3).toFloat();
                    }
                    for(int i = 0;i < currentPositionJointOut.extPositionValue.size();i++)
                    {
                        tmpPoint.extPositionValue.push_back(currentPositionJointOut.extPositionValue[i]);//float
                        tmpPoint.extPositionValue[i] = QString::number(tmpPoint.extPositionValue[i],'f',3).toFloat();
                    }
                }
                else
                {
                    tmpPoint.jointFlag = EM_CF_WORLD_TYPE;//globalData->globalCoordinate;
                    tmpPoint.pointNum = pointNumber;
                    tmpPoint.groupNum = 0;
                    tmpPoint.ufValue = globalData->globalDefaultUserNum;
                    tmpPoint.utValue = globalData->globalDefaultToolNum;
                    tmpPoint.recordStatus = 0;
                    //多圈
                    tmpPoint.configString = currentPositionDecartOut.configString;
                    tmpPoint.configInt = currentPositionDecartOut.configInt;
                    for(int i = 0;i < currentPositionDecartOut.positionValue.size();i++)
                    {
                        tmpPoint.positionValue.push_back(currentPositionDecartOut.positionValue[i]);//float
                        tmpPoint.positionValue[i] = QString::number(tmpPoint.positionValue[i],'f',3).toFloat();
                    }
                    for(int i = 0;i < currentPositionJointOut.extPositionValue.size();i++)
                    {
                        tmpPoint.extPositionValue.push_back(currentPositionJointOut.extPositionValue[i]);//float
                        tmpPoint.extPositionValue[i] = QString::number(tmpPoint.extPositionValue[i],'f',3).toFloat();
                    }
                }

//                globalData->unlock();

                //qDebug()<<tmpPoint.positionValue.size();
                if(fileData.getPointProList.size() == 0)
                {
                    fileData.getPointProList.append(tmpPoint);
                }
                else
                {

                    //新判定 方法 支持动态增加多点
                    //假设 当前有10个 添加 第15个点
                    //下标0-9  实际编号1-10
                    if(pointNumber > fileData.getPointProList.size())
                    {
                        int appendCount = pointNumber - fileData.getPointProList.size();//15-10=5
                        int tmpPointNum = fileData.getPointProList.size();
                        for(int appendNum = 0;appendNum<appendCount;appendNum++)
                        {
                            tmpPointNum++;//11-15
                            tmpPoint.pointNum = tmpPointNum;
                            fileData.getPointProList.append(tmpPoint);//不断加
                        }
                    }
                    else
                    {
                        //pointNumber-1 为数组下标
                        fileData.getPointProList.replace(pointNumber-1,tmpPoint);
                    }
                }

                bool askForSave = true;
                for(int i = 0;i<programView->fileInformation.size();i++)
                {
                    if(1!=programCheck.patExect(programView->fileInformation[i] , i))
                    {
                        //programView->messageBoxShow(tr("提示"),tr("程序语法存在错误,请修改后再保存"));
                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("程序第")+QString::number(i+1)+tr("行语法存在错误,请修改后再保存"));
                        askForSave = false;
                        break;
                    }
                }

                if(askForSave)
                {
                    //2017.04.22注释掉 不写文件
//                    fileData.cmdStrWriteList.clear();
//                    fileData.cmdStrWriteList << programView->fileInformation;
//                    fileData.writeProgramFile(fileData.currentFileName,true);

//                    QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
//                    emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);//通知更新

                    programView->isProgramFileSaved = false;
                    QString msgInfo="载入P[";
                    msgInfo+=QString::number(pointNumber)+"]点成功";
                    emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),msgInfo);
//                    emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("载入P点成功"));

                    //更新 点数据界面的 该载入点数据
                    programView->pointViewDialog->setCurrentRowToShow(pointNumber);//重新刷新当前点
                }

//            }
        }
        else
        {
            //programView->messageBoxShow(tr("提示"),tr("当前没有打开任何文件"));
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前没有打开任何文件,无法保存"));
        }
    }
}

void ProgramDelegate::recordPointInsert(int pointNumber)
{
    if(globalData)
    {
        PointPro currentPositionJointOut;
        globalData->getCurrentArmPosition_joint(currentPositionJointOut);
        PointPro currentPositionDecartOut;
        globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
        if(fileData.currentFileName != "")
        {
            //usleep(50000);//50ms
            //获取当前点数据(判断当前是关节坐标还是世界坐标)
//            if(globalData->tryLock(TRYLOCKTIME))
//            {
                fileData.globalDefaultUserNum = globalData->globalDefaultUserNum;
                fileData.globalDefaultToolNum = globalData->globalDefaultToolNum;
                PointPro tmpPoint;

                tmpPoint.jointFlag = EM_CF_DEG_TYPE;
                tmpPoint.pointNum = pointNumber;
                tmpPoint.groupNum = 0;
                tmpPoint.ufValue = globalData->globalDefaultUserNum;
                tmpPoint.utValue = globalData->globalDefaultToolNum;
                tmpPoint.recordStatus = 0;
                //多圈 目前空
                tmpPoint.configString = "";
                for(int i = 0;i < currentPositionJointOut.positionValue.size();i++)
                {
                    tmpPoint.positionValue.push_back(currentPositionJointOut.positionValue[i]);//float
                    tmpPoint.positionValue[i] = QString::number(tmpPoint.positionValue[i],'f',3).toFloat();
                }
                for(int i = 0;i < currentPositionJointOut.extPositionValue.size();i++)
                {
                    tmpPoint.extPositionValue.push_back(currentPositionJointOut.extPositionValue[i]);//float
                    tmpPoint.extPositionValue[i] = QString::number(tmpPoint.extPositionValue[i],'f',3).toFloat();
                }

//                globalData->unlock();

                //qDebug()<<tmpPoint.positionValue.size();
                if(fileData.getPointProList.size() == 0)
                {
                    fileData.getPointProList.append(tmpPoint);
                }
                else
                {
                    //新判定 方法 支持动态增加多点
                    //假设 当前有10个 添加 第15个点
                    //下标0-9  实际编号1-10
                    if(pointNumber > fileData.getPointProList.size())
                    {
                        int appendCount = pointNumber - fileData.getPointProList.size();//15-10=5
                        int tmpPointNum = fileData.getPointProList.size();
                        for(int appendNum = 0;appendNum<appendCount;appendNum++)
                        {
                            tmpPointNum++;//11-15
                            tmpPoint.pointNum = tmpPointNum;
                            fileData.getPointProList.append(tmpPoint);//不断加
                        }
                    }
                    else
                    {
                        //pointNumber-1 为数组下标
                        fileData.getPointProList.replace(pointNumber-1,tmpPoint);
                    }
                }

                //此处不保存:修改指令后会有强制保存提示
//                bool askForSave = true;
//                for(int i = 0;i<programView->fileInformation.size();i++)
//                {
//                    if(programCheck.patExect(programView->fileInformation[i] , i) == ERR)
//                    {
//                        //programView->messageBoxShow(tr("提示"),tr("程序语法存在错误,请修改后再保存"));
//                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("程序第")+QString::number(i+1)+tr("行语法存在错误,请修改后再保存"));
//                        askForSave = false;
//                        break;
//                    }
//                }

//                if(askForSave)
//                {
//                    fileData.cmdStrWriteList.clear();
//                    fileData.cmdStrWriteList << programView->fileInformation;
//                    fileData.writeProgramFile(fileData.currentFileName,true);

//                    QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
//                    emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);//通知更新
//                }
            }
//        }
//        else
//        {
//            //programView->messageBoxShow(tr("提示"),tr("当前没有打开任何文件"));
//            //emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前没有打开任何文件,无法保存"));
//        }
    }
}

void ProgramDelegate::showPointSlot(QString currentRow)
{
    qDebug() << currentRow << " = show point";//行指令
    //显示
    programView->pointViewDialog->show();
    programView->pointViewDialog->updateView();

    //显示数据
    //判断有无P[]
    QString pattern("(.*)\\s+P\\[(.*)\\]\\s*(.*)");
    QRegExp rx(pattern);
    int pos = currentRow.indexOf(rx);
    if ( pos >= 0 )
    {
        //qDebug() << "point number :" << rx.cap(2);
        //int pointNumber = rx.cap(2).toInt();
        int pointNumber = programView->motionInstructionView->getRrgToIndex(rx.cap(2));

        if(pointNumber>0)
        {
            programView->pointViewDialog->setCurrentRowToShow(pointNumber);
        }
    }
    else
    {
        //指令没有点,不执行任何操作
        programView->pointViewDialog->setCurrentRowToShow(1);
    }
}


void ProgramDelegate::changePointToDegSlot(int pointNum)
{
    qDebug()<<"changePointToDegSlot:"<<pointNum;

    //新判定 方法 支持动态
    if(pointNum > fileData.getPointProList.size())
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前点没有载入点数据"));
    }
    else
    {
        if(fileData.getPointProList[ pointNum-1 ].jointFlag == EM_CF_WORLD_TYPE)
        {
            emit changePointToDegCommSignal(fileData.getPointProList[ pointNum-1 ]);
        }
    }
}

void ProgramDelegate::changePointToWorldSlot(int pointNum)
{
    qDebug()<<"changePointToWorldSlot:"<<pointNum;

    //新判定 方法 支持动态
    if(pointNum > fileData.getPointProList.size())
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前点没有载入点数据"));
    }
    else
    {
        if(fileData.getPointProList[ pointNum-1 ].jointFlag == EM_CF_DEG_TYPE)
        {
            emit changePointToWorldCommSignal(fileData.getPointProList[ pointNum-1 ]);
        }
    }
}

void ProgramDelegate::recvChangePointAndSave(PointPro recvPoint)
{
    //关节点和坐标点转换后再次保存。
    qDebug()<<"ProgramDelegate::recvChangePointAndSave recvPoint１";
    if(!programView->pointViewDialog->isHidden())
    {
        qDebug()<<"ProgramDelegate::recvChangePointAndSave recvPoint２";

        if(globalData)
        {
            int recordPointNum = recvPoint.pointNum;//motionInstructionView->pointProMo.pointNum;

            //qDebug()<<motionInstructionView->pointProMo.positionValue.size();
            if(fileData.getPointProList.size() == 0)
            {
                fileData.getPointProList.append(recvPoint);
            }
            else
            {
                //新判定 方法 支持动态增加多点
                //假设 当前有10个 添加 第15个点
                //下标0-9  实际编号1-10
                if(recordPointNum > fileData.getPointProList.size())
                {
                    int appendCount = recordPointNum - fileData.getPointProList.size();//15-10=5
                    int tmpPointNum = fileData.getPointProList.size();
                    for(int appendNum = 0;appendNum<appendCount;appendNum++)
                    {
                        tmpPointNum++;//11-15
                        recvPoint.pointNum = tmpPointNum;
                        fileData.getPointProList.append(recvPoint);//不断加
                    }
                }
                else
                {
                    //pointNumber-1 为数组下标
                    fileData.getPointProList.replace(recordPointNum-1,recvPoint);
                }
            }

            //保存文件
            //qDebug()<<fileData.cmdStrWriteList;
            fileData.writeProgramFile(fileData.currentFileName,true);

            QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
            emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);
            QString msgInfo="载入P[";
            msgInfo+=QString::number(recordPointNum)+"]点成功";
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),msgInfo);
//            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("载入P点成功"));

            //更新 点数据界面的 该载入点数据
            programView->pointViewDialog->setCurrentRowToShow(recordPointNum);//重新刷新当前点

        }
    }
}


void ProgramDelegate::jToPointSlot(int currentLineIndex)
{
    //qDebug() << currentLineIndex << "jToPoint";
    moveToPointSlot(0 , currentLineIndex);
}

void ProgramDelegate::lToPointSlot(int currentLineIndex)
{
    //qDebug() << currentLineIndex << "lToPoint";
    moveToPointSlot(1 , currentLineIndex);
}

void ProgramDelegate::pointViewjMoveSlot(int pointNum)
{
    //qDebug() << currentLineIndex << "jToPoint";
    moveToPointSlotByNum(0 , pointNum);
}

void ProgramDelegate::pointViewlMoveSlot(int pointNum)
{
    //qDebug() << currentLineIndex << "lToPoint";
    moveToPointSlotByNum(1 , pointNum);
}


void ProgramDelegate::moveToPointSlot(int moveType , int currentLineIndex)
{
    qDebug()<<"start";

    if(currentLineIndex<0)
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前文件没有选中行"));
        return;
    }
    if(globalData)
    {

        std::vector<PointPro > pointregisterOut;
        ioData->getPointRegister(pointregisterOut);
        if(fileData.currentFileName != "")
        {
            //qDebug() << currentLineIndex << "record point";

            QString tmp = currentProgram[currentLineIndex];
            //qDebug() << tmp;

            //判断有无P[]
            QString pattern("(.*)\\s+(P|PR)\\[(R\\[\\d+\\]|\\d+)\\]\\s*(.*)");
            QRegExp rx(pattern);
            int pos = tmp.indexOf(rx);
            if ( pos >= 0 )
            {
                qDebug() << "point number :" << rx.cap(3);
                //int pointNumber = rx.cap(2).toInt();
                int pointNumber = programView->motionInstructionView->getRrgToIndex(rx.cap(3));
                if(pointNumber <= 0)
                {
                    emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("该点编号不合法!"));
                    return;
                }

                //************************
                int arrayNumber = 0;//下标
                MoveParameter tmpMoveParameter;

                if("P" == rx.cap(2))
                {
                    if(fileData.getPointProList.size() == 0)
                    {
                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前点没有载入点数据"));
                        return;
                    }
//                    for(int i = 0;i < fileData.getPointProList.size();i++)
//                    {
//                        if(fileData.getPointProList[i].pointNum == pointNumber)
//                        {
//                            arrayNumber = i;
//                            break;//该点数据存在
//                        }
//                        else
//                        {
//                            //不存在该下标的当前点
//                            if(i == fileData.getPointProList.size()-1)
//                            {
//                                emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前点没有载入点数据"));
//                                return ;
//                            }
//                        }
//                    }
                    //新判定 方法 支持动态
                    if(pointNumber > fileData.getPointProList.size())
                    {
                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前点没有载入点数据"));
                        return ;
                    }
                    else
                    {
                        arrayNumber = pointNumber-1;//该点存在,获取下标
                    }

                    tmpMoveParameter.moveType = moveType;

//                    tmpMoveParameter.targetPoint.jointFlag = fileData.getPointProList[arrayNumber].jointFlag;
//                    tmpMoveParameter.targetPoint.pointNum = fileData.getPointProList[arrayNumber].pointNum;
//                    tmpMoveParameter.targetPoint.groupNum = fileData.getPointProList[arrayNumber].groupNum;
//                    tmpMoveParameter.targetPoint.ufValue = fileData.getPointProList[arrayNumber].ufValue;
//                    tmpMoveParameter.targetPoint.utValue = fileData.getPointProList[arrayNumber].utValue;
//                    tmpMoveParameter.targetPoint.recordStatus = 0;
//                    //多圈 目前空
//                    tmpMoveParameter.targetPoint.configString = fileData.getPointProList[arrayNumber].configString;
//                    //tmpMoveParameter.targetPoint.configInt = ;//int
//                    for(int i = 0;i < fileData.getPointProList[arrayNumber].positionValue.size();i++)
//                    {
//                        tmpMoveParameter.targetPoint.positionValue.push_back(fileData.getPointProList[arrayNumber].positionValue[i]);//float
//                    }
//                    for(int i = 0;i < fileData.getPointProList[arrayNumber].extPositionValue.size();i++)
//                    {
//                        tmpMoveParameter.targetPoint.extPositionValue.push_back(fileData.getPointProList[arrayNumber].extPositionValue[i]);//float
//                    }
                    tmpMoveParameter.targetPoint = fileData.getPointProList[arrayNumber];

                    tmpMoveParameter.pointType = 0;//普通点
                }
                else if ("PR" == rx.cap(2))
                {
//                    ioData->lock();
                    if(pointNumber > pointregisterOut.size())
                    {
//                        ioData->unlock();
                        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("PR点不存在,请修改"));
                        return ;
                    }
                    else
                    {
                        arrayNumber = pointNumber-1;//该点存在,获取下标
                    }

                    tmpMoveParameter.moveType = moveType;

//                    tmpMoveParameter.targetPoint.jointFlag = fileData.getPointProList[arrayNumber].jointFlag;
//                    tmpMoveParameter.targetPoint.pointNum = fileData.getPointProList[arrayNumber].pointNum;
//                    tmpMoveParameter.targetPoint.groupNum = fileData.getPointProList[arrayNumber].groupNum;
//                    tmpMoveParameter.targetPoint.ufValue = fileData.getPointProList[arrayNumber].ufValue;
//                    tmpMoveParameter.targetPoint.utValue = fileData.getPointProList[arrayNumber].utValue;
//                    tmpMoveParameter.targetPoint.recordStatus = 0;
//                    //多圈 目前空
//                    tmpMoveParameter.targetPoint.configString = fileData.getPointProList[arrayNumber].configString;
//                    //tmpMoveParameter.targetPoint.configInt = ;//int
//                    for(int i = 0;i < fileData.getPointProList[arrayNumber].positionValue.size();i++)
//                    {
//                        tmpMoveParameter.targetPoint.positionValue.push_back(fileData.getPointProList[arrayNumber].positionValue[i]);//float
//                    }
//                    for(int i = 0;i < fileData.getPointProList[arrayNumber].extPositionValue.size();i++)
//                    {
//                        tmpMoveParameter.targetPoint.extPositionValue.push_back(fileData.getPointProList[arrayNumber].extPositionValue[i]);//float
//                    }

                    tmpMoveParameter.targetPoint = pointregisterOut[arrayNumber];
//                    ioData->unlock();

                    tmpMoveParameter.pointType = 0;//普通点
                }

                //emit moveToPointSignal(tmpMoveParameter);
                //新方法
                moveOperation->startPointMove(tmpMoveParameter);
            }
            else
            {
                //programView->messageBoxShow(tr("提示"),tr("当前选择语句无法载入点数据"));
                emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前选择语句没有点数据"));
            }

        }
        else
        {
            //programView->messageBoxShow(tr("提示"),tr("当前没有打开任何文件"));
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前没有打开任何文件"));
        }
    }
}


void ProgramDelegate::moveToPointSlotByNum(int moveType, int pointNumber)
{
    int arrayNumber = 0;//下标
    if(fileData.getPointProList.size() == 0)
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前点没有载入点数据"));
        return;
    }

    //新判定 方法 支持动态
    if(pointNumber > fileData.getPointProList.size())
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前点没有载入点数据"));
        return ;
    }
    else
    {
        arrayNumber = pointNumber-1;//该点存在,获取下标
    }

    MoveParameter tmpMoveParameter;
    tmpMoveParameter.moveType = moveType;
    //tmpMoveParameter.targetPoint = fileData.getPointProList[pointNumber];

    tmpMoveParameter.targetPoint.jointFlag = fileData.getPointProList[arrayNumber].jointFlag;
    tmpMoveParameter.targetPoint.pointNum = fileData.getPointProList[arrayNumber].pointNum;
    tmpMoveParameter.targetPoint.groupNum = fileData.getPointProList[arrayNumber].groupNum;
    tmpMoveParameter.targetPoint.ufValue = fileData.getPointProList[arrayNumber].ufValue;
    tmpMoveParameter.targetPoint.utValue = fileData.getPointProList[arrayNumber].utValue;
    tmpMoveParameter.targetPoint.recordStatus = 0;
    //多圈 目前空
    tmpMoveParameter.targetPoint.configString = fileData.getPointProList[arrayNumber].configString;
    //tmpMoveParameter.targetPoint.configInt = ;//int
    for(int i = 0;i < fileData.getPointProList[arrayNumber].positionValue.size();i++)
    {
        tmpMoveParameter.targetPoint.positionValue.push_back(fileData.getPointProList[arrayNumber].positionValue[i]);//float
    }
    for(int i = 0;i < fileData.getPointProList[arrayNumber].extPositionValue.size();i++)
    {
        tmpMoveParameter.targetPoint.extPositionValue.push_back(fileData.getPointProList[arrayNumber].extPositionValue[i]);//float
    }

    tmpMoveParameter.pointType = 0;//普通点

    //emit moveToPointSignal(tmpMoveParameter);
    //新方法
    moveOperation->startPointMove(tmpMoveParameter);
}

void ProgramDelegate::setCoupleControl_slot(int followAxisId, bool isEnable)
{
    int tmpKey;
    communicateNormalDelegate->setCoupleControlEnable(followAxisId,isEnable,tmpKey);
    if(1==tmpKey)
    {
        if(isEnable)
        {
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("跟随使能设置成功"));
        }
        else
        {
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("跟随解除设置成功"));
        }

    }
    else
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("跟随设置失败"));
    }
}



void ProgramDelegate::timeOrderWork()
{
    //程序运行状态不判断
    if(ENUM_COMMAND_RUN==globalData->globalCurrentState)
    {
        return ;
    }

    //判断程序版本号是否有冲突
    if(EM_CONNECT_SUCCESS == globalData->controllerIsConnected )
    {
        //判断远程文件名称是否变换
        static QString staticFileName="";
        static QString tmpFileName;
        globalData->getCurrentRunMainFileName(tmpFileName);
        if( (""!=staticFileName) &&
                (staticFileName!=tmpFileName))
        {
            QString info=tr("控制器已经更换当前用户程序文件，\n即将重新加载新程序文件! ");
            info+=tmpFileName;
            qDebug()<<info<<"staticFileName"<<staticFileName;
            emit openUserProgramFile_signal(tmpFileName);
        }

//        CurrentRunFile currentRunFileOut;
//        globalData->getCurrentRunFile(currentRunFileOut);
//        if(currentRunFileOut.relatedFileName.size()>0)
//        {
//            if(""!=staticFileName && staticFileName.toStdString()==currentRunFileOut.relatedFileName[0])
//            {

//            }
//        ｝
        staticFileName=tmpFileName;

        //判断版本是否变
        static int versionOld=0;
        if( (0!=versionOld) &&
                (versionOld!=globalData->mainProgramFileVersion) &&
                (globalData->mainProgramFileVersion != fileData.programFileVersion))
        {
            QString fileName;
            fileData.getCurrentFileName(fileName);

            CurrentRunFile currentRunFileOut;
            globalData->getCurrentRunFile(currentRunFileOut);
            if(currentRunFileOut.relatedFileName.size()>0)
            {
                if(""!=fileName && fileName.toStdString()==currentRunFileOut.relatedFileName[0])
                {
                    emit msgBoxGsoapWrite_Signal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前用户程序文件已经被修改，\n即将重新加载新版本程序文件!"));
                    emit openUserProgramFile_signal(fileName);
                }
            }


        }
        versionOld=globalData->mainProgramFileVersion;
    }

}

void ProgramDelegate::initialMusicFileList()
{
    //music file list
    std::vector<std::string> tmpFileList;
    communicateNormalDelegate->getFileList(2,tmpFileList);//有时候会导致ｇsoap卡这里。
    programView->musicInstructionDelegate->setMusicFileList_std(tmpFileList);
}

void ProgramDelegate::stopMoveToPointSlot()
{
    qDebug()<<"stop";
    //emit stopMoveToPointSignal();
    moveOperation->stopPointMove();
}

void ProgramDelegate::saveFileSlot()
{
//    if(globalData->tryLock(TRYLOCKTIME))
//    {
        if(globalData->globalCurrentState == ENUM_COMMAND_RUN || globalData->globalCurrentState == ENUM_COMMAND_CEASE )
        {
            //qDebug()<<"globalData->globalCurrentState = "<<globalData->globalCurrentState;
//            globalData->unlock();
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("机器程序正在运行中！！！\n请点击停止按钮后再保存程序"));
            return;//return 0 ;
        }

        if(globalData->getUserInfo().account < EM_ACCOUNT_ADMIN)
        {
//            globalData->unlock();
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("您当前用户没有操作权限\n请切换用户角色"));
            return;//return 0;
        }

//        globalData->unlock();
//    }
//    if(cmdChangeFlag)
//    {
    if(fileData.currentFileName != "")
    {
        int count = fileData.cmdStrList.size();
        if(count == programView->fileInformation.size())
        {
            for(int i = 0;i<count;i++)
            {
                if(fileData.cmdStrList[i] != programView->fileInformation[i])
                {
                    break;
                }
                else
                {
                    if(i == count-1)
                    {
//                        if(0 == programView->isSave)
//                        {
//                            programView->isSave = 1;//当作是已经保存
//                            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("程序已保存"));//修改后 但实际文件内容没有变化
//                        }
//                        else
                        if(programView->isProgramFileSaved)//保存过
                        {
                            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("程序没有修改"));

                            return;//return 1;//全部一致,无需重写
                        }

                        //return;//return 1;//全部一致,无需重写
                    }
                }
            }
        }

        ///////////
        //clock_t start,finish;
        //start=clock();

        bool askForSave = true;
        for(int i = 0;i<programView->fileInformation.size();i++)
        {
            if(1!=programCheck.patExect(programView->fileInformation[i] , i))
            {
                //programView->messageBoxShow(tr("提示"),tr("程序语法存在错误,请修改后再保存"));
                emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("程序第")+QString::number(i+1)+tr("行语法存在错误,请修改后再保存"));
                askForSave = false;
                break;
            }
        }

        //finish=clock();
        //qDebug()<<"save file ********************** check program:"<<finish-start;
        //start=clock();

        //普通语句的正则合法判断结束后,检查码垛块的合法性
        int palWarnNum = programCheck.checkPalletCmdList(false,"",0);//false = 非初始化
        if(palWarnNum > 0)
        {
            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("第")+QString::number(palWarnNum)+tr("个码垛块存在错误,请修改后再保存"));
            askForSave = false;
        }

        //finish=clock();
        //qDebug()<<"save file ********************** check pallet:"<<finish-start;

        if(askForSave)
        {
            fileData.cmdStrWriteList.clear();
            fileData.cmdStrWriteList << programView->fileInformation;
            //qDebug()<<"fileData.cmdStrWriteList";
            //qDebug()<<fileData.cmdStrWriteList;

            //start=clock();

            // 写入数据至程序文件
            fileData.writeProgramFile(fileData.currentFileName,true);

            programView->isProgramFileSaved = true;

            //finish=clock();
            //qDebug()<<"save file ********************** write program:"<<finish-start;

            //标志位更新 用于runview重刷 缓存cmdlist
            fileData.cmdStrList.clear();
            fileData.cmdStrList << fileData.cmdStrWriteList;
            fileData.cmdStrWriteSuccess = true;//runview的更新

            // GSOAP传输文件
            if(GSOAP_OPERATE_PROGRAM_FILE_SWITCH)
            {

                QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
                qDebug()<<"md5:"<<md5;
                emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);
                if(fileData.isGsoapFileWriteFlag)
                {
                    emit msgBoxGsoapWrite_Signal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("保存成功!"));
                }
                else
                {
                    emit msgBoxGsoapWrite_Signal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("保存失败!"));
                    fileData.isGsoapFileWriteFlag = false;
                    return;
                }
            }
            // 普通FTP传输文件
            else
            {
                if(globalData->isUseFtpOrNfs)
                {
                    fileData.ftpOperateNum = EM_FTP_OPERATE_SAVE_FILE;
                    // 程序文件保存后上传至 FTP 服务器program目录下
                    ftpManage->ftpPutFile(fileData.currentFileName, (fileData.currentRobotFileAddress + "program/"), PROGRAM_PATH);
                }
                else
                {
                    QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
                    qDebug()<<"md5:"<<md5;
                    emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);
                }

            }

            // 绘制目标点到地图上
            emit showPointInMap();
//            emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("保存成功"));
        }
    }
    else
    {
        programView->isProgramFileSaved = true;
        //programView->messageBoxShow(tr("提示"),tr("当前没有打开任何文件"));
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("当前无文件"));
    }

//    }
    //qDebug() << fileName << fileInformation ;
    qDebug() << "save isSave = " << programView->isProgramFileSaved;
}

/*****************************************
 * 修改人:        hualei
 * 修改时间:    20118-07-11
 * 修改说明:    修改资源文件路径
 *
 * ***************************************/
void ProgramDelegate::menuViewShowOrHideSlot(int menuViewShowFlag)
{
    if(1 == menuViewShowFlag)
    {
        qDebug() << "menu hide";
        programView->menuViewShowFlag = 0;
        programView->hideOrShowBtnPicture = "/agvwork/AgvHmi/baseBag/hmiProject/resources/programsources/page/program_forward_n.png";
    }
    else
    {
        qDebug() << "menu show";
        programView->menuViewShowFlag = 1;
        programView->hideOrShowBtnPicture = "/agvwork/AgvHmi/baseBag/hmiProject/resources/programsources/page/program_next_n.png";
    }

    programView->updateView(false,true);
}

//void ProgramDelegate::menuChangeSlot(int currentMenuIndex)
void ProgramDelegate::menuChangeSlot()
{
    if(0 == instructionListViewFlag)
    {
        qDebug() << "change page btn";

        programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
        programView->menuBtnTitle = tr("全部指令");
        programView->updateView(false,true);

        instructionListViewFlag = 1;
    }

    else if(1 == instructionListViewFlag)
    {
        qDebug() << "change page btn";

        programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_USUALY1;
        programView->menuBtnTitle = tr("常用指令");
        programView->updateView(false,true);

        instructionListViewFlag = 0;
    }
}

void ProgramDelegate::rightFunMoveToPointSlot(int type)
{
    if(!programView->isHidden())
    {
        qDebug()<<"programView ok "<< type<<":"<<programView->currentLineIndex;
        moveToPointSlot(type,programView->currentLineIndex);
    }
}

void ProgramDelegate::rightFunMoveStopSlot()
{
    if(!programView->isHidden())
    {
        moveOperation->stopPointMove();
    }
}

void ProgramDelegate::oftenForwardPageSlot()
{
//    programView->instructionMenu_usualyUsed2->hide();
//    programView->instructionMenu_usualyUsed1->show();
    qDebug() << "USUALY２ Forward Page";
    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_USUALY1;
    programView->updateView(false, true);
}

void ProgramDelegate::oftenNextPageSlot()
{
//    programView->instructionMenu_usualyUsed1->hide();
//    programView->instructionMenu_usualyUsed2->show();
    qDebug() << "USUALY１ Next Page";
    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_USUALY2;
    programView->updateView(false, true);
}

void ProgramDelegate::allForwardPageSlot()
{
    qDebug() << "all Forward Page";
}

void ProgramDelegate::allNextPageSlot()
{
    qDebug() << "all Next Page";
}

bool ProgramDelegate::instructionIsArc()
{
    if(programView->getCurrentLineIndex() >= 0)
    {
        QString instruction = currentProgram[programView->getCurrentLineIndex()];
        QRegExp rx("^\\s*([C])\\s+(.*)$");
        instruction.indexOf(rx);

        if("C" == rx.cap(1))
        {
            return true;
        }
    }
    return false;
}

int ProgramDelegate::setMusicFileList(QVector<QString> musicFileListIn)
{
    return programView->musicInstructionDelegate->setMusicFileList(musicFileListIn);
}

void ProgramDelegate::jInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

//        instruction = tr("J P[") + index + tr("] 100% FINE; ") + "//";
        instruction = tr("J P[") + index + tr("] ")+QString::number(defaultJMoveSpeed)+tr("% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        qDebug() << "J instruction";
        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::lInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);

        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);

//        QString instruction = tr("L P[") + index + tr("] 100% FINE; ") + "//";
        QString instruction = tr("L P[") + index + tr("] ")+QString::number(defaultLMoveSpeed);

        instruction+=defaultUniteType+tr(" FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        qDebug() << "L instruction";
        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::axisMoveInstruction_Slot()
{
    if(! instructionIsArc())
    {

        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;


        QString instruction = tr("AXISMOVE AXIS[0] 100% TARGET0.00 MAPREFERENCE;//") ;

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        qDebug() << instruction;

        programView->updateView(true,true);
    }
}

void ProgramDelegate::arcInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction1 = tr("C P[") + QString::number(maxUsedPointIndex) + "];";
        maxUsedPointIndex++;
        QString instruction2 = tr("  P[") + QString::number(maxUsedPointIndex) + tr("] 100% FINE; ") + "//";
        recordPointInsert(maxUsedPointIndex);//预先载入点

        currentProgram.insert(programView->currentLineIndex, instruction1);
        programView->currentLineIndex ++;
        currentProgram.insert(programView->currentLineIndex, instruction2);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);

        qDebug() << "Arc instruction";
    }
}

void ProgramDelegate::labelInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("LBL[1]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "Label instruction";
    }
}

void ProgramDelegate::jumpInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("JMP LBL[1]; ") + "// ";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "Jump instruction";
    }
}

void ProgramDelegate::conditionInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("IF R[1]=1,  JMP LBL[1]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "Condition instruction";
    }
}

void ProgramDelegate::waitInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("WAIT 1sec; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "Wait instruction";
    }
}

void ProgramDelegate::openMoveMenuSlot()
{
    qDebug() << "open move menu";

    programView->currentMenuIndex = EM_MENUINDEX_MOVEMENU;
    programView->updateView(false,true);
}

void ProgramDelegate::openPalletMenuSlot()
{
    qDebug() << "open pallet menu";

    programView->currentMenuIndex = EM_MENUINDEX_PALLETMENU;
    programView->updateView(false,true);
}

void ProgramDelegate::openFlowMenuSlot()
{
    qDebug() << "open flow menu";

    programView->currentMenuIndex = EM_MENUINDEX_FLOWMENU;
    programView->updateView(false,true);
}

void ProgramDelegate::openRegisterMenuSlot()
{
    qDebug() << "open register menu";

    programView->currentMenuIndex = EM_MENUINDEX_REGISTERMENU ;
    programView->updateView(false,true);
}

void ProgramDelegate::openIoMenuSlot()
{
    qDebug() << "open I/O menu";

    programView->currentMenuIndex = EM_MENUINDEX_IOMENU;
    programView->updateView(false,true);
}

void ProgramDelegate::openOtherMenuSlot()
{
    qDebug() << "open other menu";

    programView->currentMenuIndex = EM_MENUINDEX_OTHERMENU ;
    programView->updateView(false,true);
}

void ProgramDelegate::openStampingMenuSlot()
{
    qDebug() << "open stamping menu";

    programView->currentMenuIndex = EM_MENUINDEX_STAMPINGMENU ;//2017.05.05
    programView->updateView(false,true);
}

void ProgramDelegate::openWeldMenuSlot()
{
    qDebug() << "open Weld menu";

    programView->currentMenuIndex = EM_MENUINDEX_WELDMENU ;//2017.05.05
    programView->updateView(false,true);
}

/**********************************************************
 * 修改者：          hualei
 * 修改时间:    (1) 2018-06-21
 *              (2) 2018-08-01
 *
 * 修改说明：　  1- 增加MOVE_MAG、MOVE_FREE 导航指令视窗响应槽函数
 *               2- 增加打开　TCP 以太网通信指令菜单窗口响应槽函数
 *
 * *******************************************************/
void ProgramDelegate::openGuidanceMenuSlot()
{
    qDebug() << "Open Guidance Menu";
    programView->currentMenuIndex = EM_MENUINDEX_GUIDANCEMENU;
    programView->updateView(false, true);

}

void ProgramDelegate::openModbusMenuSlot()
{
    qDebug() << "Open Modbus Menu";
    programView->currentMenuIndex = EM_MENUINDEX_MODBUSMENU;
    programView->updateView(false, true);

}

void ProgramDelegate::openTcpCommunicationSlot()
{
    qDebug() << "Open TCP Communication Menu";

    programView->currentMenuIndex = EM_MENUINDEX_TCPMENU;
    programView->updateView(false, true);
}

void ProgramDelegate::guidanceMoveMagSlot()
{
    // 判断是否为　"C" 指令
    if(!instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;
//        if(programView->moveMagInstructionView->leftMiddleRight == 0)
//        {
//            motionDirection = "L";
//        }
//        else if(programView->moveMagInstructionView->leftMiddleRight == 1)
//        {
//            motionDirection = "M";
//        }
//        else if(programView->moveMagInstructionView->leftMiddleRight == 2)
//        {
//            motionDirection = "R";
//        }

        QString instruction = tr("MOVE_MAG") + tr(" M ");

//        if(programView->moveMagInstructionView->frontBack == 0)
//        {
//            motionDirection = "FRONT";
//        }
//        else if(programView->moveMagInstructionView->frontBack == 1)
//        {
//            motionDirection = "BACK";
//        }
        instruction += tr(" FRONT ");

//        int velocityRatio = programView->moveMagInstructionView->velocityRatio;
//        instruction += (" " + QString("%1").arg(velocityRatio) + "%,RFID ");

//        QString rfidValue = programView->moveMagInstructionView->rfidValue;
//        instruction += rfidValue;

        instruction += "100%," + tr("RFID 1") + " //";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "MOVE_MAG instruction";
    }
    else
    {

    }

}

void ProgramDelegate::guidanceMoveFreeSlot()
{
    if(!instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        int index = 0;
        QVector <QString> moveFreeInstructionList;
        // 将界面指令列表中找出符合自由导航的指令缓存
        for(int i = 0; i < programView->fileInformation.count(); i++)
        {
            if(programView->fileInformation.at(i).contains("MOVE_FREE"))
            {
                moveFreeInstructionList.append(programView->fileInformation.at(i));
            }
        }
        if(moveFreeInstructionList.isEmpty())
        {
            index = 0;
        }
        else
        {
            QList <int> dpointIndexList;

            for(int i =0; i < moveFreeInstructionList.count(); i++)
            {
                Line lineOut;
                programRegExp->patMoveFree(moveFreeInstructionList[i],lineOut);
                if(E_MOVE_FREE_POINTS_ARRY_DP==lineOut.moveFreeInstruction.pointArryType)
                {
                    dpointIndexList <<lineOut.moveFreeInstruction.pointsValue;
                }


            }
            // 排序找出DP最大值

            if(dpointIndexList.size()>0)
            {
                qSort(dpointIndexList.begin(), dpointIndexList.end());
                index = dpointIndexList.last();
            }

        }

        index += 1;
        QString instruction = tr("MOVE_FREE") + tr(" DP[")+  QString::number(index)\
                + ("] ")  + "100%," + tr("IMU,") + tr("FINE,") + tr("LINE,") +tr("P,0.25,") + tr("OP,") + tr("Laser[0],") + tr("DET0,") + tr("JMP LB[1]") +tr("  //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->moveFreeInstructionView->moveFreeInstructionTrackView->saveFlag = false;
        programView->updateView(true, true);
    }
    qDebug() << "Move Free Guidance Instruction";
}

void ProgramDelegate::guidanceForwardPageSlot()
{
    qDebug() << "Guidance Menu Forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false, true);

}

void ProgramDelegate::guidanceNextPageSlot()
{
    qDebug() << "Guidance Menu Next";
}

//void ProgramDelegate::guidanceSetOdometrySlot()
//{
//    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

//    QString instructionStr = tr("SET_ODOM ");
//    instructionStr += "0.000,0.000,0.000";
//    instructionStr += tr("  //");

//    currentProgram.insert(programView->currentLineIndex, instructionStr);

//    programView->fileInformation = currentProgram;
//    programView->updateView(true, true);

//    qDebug() << "Guidance Set Odometry Instruction!";

//}

void ProgramDelegate::modbusStartSlot()
{
    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

    QString instructionStr = tr("MODBUS_START ,");
    instructionStr += tr("1,RS485,") + tr("MASTER,") + tr("JMP LB[1]");
    instructionStr += tr("  //");

    currentProgram.insert(programView->currentLineIndex, instructionStr);

    programView->fileInformation = currentProgram;

    programView->updateView(true, true);

    qDebug() << "Modbus Start Instruction";

}

void ProgramDelegate::modbusReadSlot()
{
    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

    QString instructionStr = tr("MODBUS_READ ,");
    instructionStr += tr("R[1],") + "1, 1," + tr("RS485,") + tr("MASTER,");
    instructionStr += tr("JMP LB[1]") + tr("  //");

    currentProgram.insert(programView->currentLineIndex, instructionStr);

    programView->fileInformation = currentProgram;

    programView->updateView(true, true);

    qDebug() << "Modbus Read Instruction";

}

void ProgramDelegate::modbusWriteSlot()
{
    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

    QString instructionStr = tr("MODBUS_WRITE ,");
    instructionStr += tr("R[1],") + "1,1," + tr("RS485,") + tr("MASTER,");
    instructionStr += tr("JMP LB[1] ") + tr(" //");

    currentProgram.insert(programView->currentLineIndex, instructionStr);

    programView->fileInformation = currentProgram;
    programView->updateView(true, true);

    qDebug() << "Modbus Write Instrcution";
}

void ProgramDelegate::modbusForwardPageSlot()
{
    qDebug() << "Modbus Forward Page";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false, true);

}

void ProgramDelegate::modbusNextPageSlot()
{
    qDebug() << "Modbus Instruction Next Page";
}

void ProgramDelegate::setOdomResetSlot()
{
    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

    QString instructionStr = tr("SET_ODOM ");
    instructionStr += "0.000,0.000,0.000";
    instructionStr += tr("  //");

    currentProgram.insert(programView->currentLineIndex, instructionStr);

    programView->fileInformation = currentProgram;
    programView->updateView(true, true);

    qDebug() << "Set Odometry Instruction!";

}

void ProgramDelegate::tcpStartSlot()
{
    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

    QString instructionStr = tr("TCP_START ");
    instructionStr += tr("127.0.0.1") + ",";
    instructionStr += tr("5050") + "," +  tr("CLIENT") + ",";
    instructionStr += tr("JMP ") + tr("LB") + "[1] ";
    instructionStr += tr(" //");

    currentProgram.insert(programView->currentLineIndex, instructionStr);

    programView->fileInformation = currentProgram;
    programView->updateView(true, true);

    qDebug() << "TCP Start Communication Instruction!";
}

void ProgramDelegate::tcpReadSlot()
{
    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

    QString instructionStr = tr("TCP_READ ");
    instructionStr += tr("R[1]") + "," + tr("R[1]") + ",";
    instructionStr += tr("192.168.111.36") + "," + tr("5050") + ",";
    instructionStr += tr("CLIENT") + ",";
    instructionStr += tr("JMP ") + tr("LB[1] ") + tr("//");

    currentProgram.insert(programView->currentLineIndex, instructionStr);

    programView->fileInformation = currentProgram;
    programView->updateView(true, true);

    qDebug() << "TCP Read Instruction!";

}

void ProgramDelegate::tcpWriteSlot()
{
    programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

    QString instructionStr = tr("TCP_WRITE ");
    instructionStr += tr("R[1]") + "," + tr("R[1]") + ",";
    instructionStr += tr("192.168.111.36") + "," + tr("5050") + ",";
    instructionStr += tr("CLIENT") + ",";
    instructionStr += tr("JMP ") + tr("LB[1] ") + tr("//");

    currentProgram.insert(programView->currentLineIndex, instructionStr);

    programView->fileInformation = currentProgram;
    programView->updateView(true, true);

    qDebug() << "TCP Write Instruction!";
}

void ProgramDelegate::tcpForwardPageSlot()
{
    qDebug() << "TCP menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false,true);
}

void ProgramDelegate::tcpNextPageSlot()
{
    qDebug() << "TCP Menu Next";
}

void ProgramDelegate::moveForwardPageSlot()
{
    qDebug() << "move menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false,true);
}

void ProgramDelegate::moveNextPageSlot()
{
    qDebug() << "move menu next";
}

void ProgramDelegate::palletForwardPageSlot()
{
    qDebug() << "pallet menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false,true);
}

void ProgramDelegate::palletNextPageSlot()
{
    qDebug() << "pallet menu next";
}

void ProgramDelegate::palletHeadInstructionSlot()//2017.05.24 修改对于初始化时候的处理,满足控制器初始化不出错
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("PALLETIZING-1") + tr("; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);



        qDebug() << "pallet Head Instruction";
    }
}

void ProgramDelegate::palletTailInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("PALLETIZING-END")+ tr("; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "pallet Tail Instruction";




    }
}


void ProgramDelegate::approachPointInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        int currentPalletIndex = 1;
        int number = 1;
        QString instruction = tr("L PAL_") + QString::number(currentPalletIndex) +("[A_")
                + QString::number(number) + tr("] 100% FINE; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        //programView->currentLineIndex --;//取消逆向
        programView->fileInformation = currentProgram;

    }
    programView->updateView(true,true);
}

void ProgramDelegate::fleePointInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        int currentPalletIndex = 1;
        int number = 1;
        QString instruction = tr("L PAL_") + QString::number(currentPalletIndex) +("[R_")
                + QString::number(number) + tr("] 100% FINE; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        //programView->currentLineIndex --;//取消逆向
        programView->fileInformation = currentProgram;

    }
    programView->updateView(true,true);

}

void ProgramDelegate::stackPointInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        int currentPalletIndex = 1;
        QString instruction = tr("L PAL_") + QString::number(currentPalletIndex) +("[BTM")
                + tr("] 100% FINE; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        //programView->currentLineIndex --;//取消逆向
        programView->fileInformation = currentProgram;

    }
    programView->updateView(true,true);
}

void ProgramDelegate::flowForwardPageSlot()
{
    qDebug() << "flow menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false,true);
}

void ProgramDelegate::flowNextPageSlot()
{
    qDebug() << "flow menu next";
}

void ProgramDelegate::selectInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("SELECT R[1]=1,  JMP LBL[1]; ") + "//";
        QString instruction2 = tr("ELSE, JMP LBL[2]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->currentLineIndex ++;
        currentProgram.insert(programView->currentLineIndex, instruction2);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "select Instruction";
    }
}

void ProgramDelegate::loopInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("FOR R[1]=1 TO 5; ") + "//";
        QString instructionTail = tr("ENDFOR");

        currentProgram.insert(programView->currentLineIndex, instruction);
        currentProgram.insert(programView->currentLineIndex + 1, instructionTail);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "loop Instruction";
    }
}

void ProgramDelegate::callInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("CALL programName.txt; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "call Instruction";
    }
}

void ProgramDelegate::pauseInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("PAUSE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "pause Instruction";
    }
}

void ProgramDelegate::createTaskInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("RUN programName.txt; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "create Task Instruction";
    }
}

void ProgramDelegate::abortInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("ABORT; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "end Instruction";
    }
}

void ProgramDelegate::endInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("END; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "over Instruction";
    }
}

void ProgramDelegate::registerForwardPageSlot()
{
    qDebug() << "register menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false,true);
}

void ProgramDelegate::registerNextPageSlot()
{
    qDebug() << "register menu next";
}

void ProgramDelegate::rInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("R[1]=1; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "R Instruction";
    }
}

void ProgramDelegate::pRInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("PR[1]=PR[2]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "PR Instruction";
    }
}

void ProgramDelegate::pLInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("PL[1]=[1,2,3]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "RL Instruction";
    }
}

void ProgramDelegate::timerInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("TIMER[1]=STOP; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "timer Instruction";
    }
}

void ProgramDelegate::ioForwardPageSlot()
{
    qDebug() << "io menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->menuBtnTitle = tr("全部指令");
    programView->updateView(false,true);
}

void ProgramDelegate::ioNextPageSlot()
{
    qDebug() << "io menu next";
}

void ProgramDelegate::numberInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("DO[1]=ON; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "number Instruction";
    }
}

void ProgramDelegate::analogInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("AO[1]=1; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "analog Instruction";
    }
}

void ProgramDelegate::systemInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("RO[1]=ON; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "system Instruction";
    }
}

void ProgramDelegate::otherForwardPageSlot()
{
    qDebug() << "other menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false,true);
}

void ProgramDelegate::otherNextPageSlot()
{
//    programView->otherMenu1->close();
//    programView->otherMenu2->show();

    programView->currentMenuIndex = EM_MENUINDEX_OTHERMENU_NEXT;
    programView->updateView(false,true);
}

void ProgramDelegate::toolCoordinateInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("UTOOL[1]=PR[1]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "toolCoordinate Instruction";
    }
}

void ProgramDelegate::userCoordinateInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("UFRAME[1]=PR[1]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "userCoordinate Instruction";
    }
}

void ProgramDelegate::toolCompensateInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Tool_Offset PR[1]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "toolCompensate Instruction";
    }
}

void ProgramDelegate::positionCompensateInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Offset PR[1]; ") + "//" ;

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "positionCompensate Instruction";
    }
}

void ProgramDelegate::rateInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("OVERRIDE=100%; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "rate Instruction";
    }
}

void ProgramDelegate::messageInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("MESSAGE[message]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "message Instruction";
    }
}

void ProgramDelegate::alarmInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("UALM[UALMINFO]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "alarm Instruction";
    }
}

void ProgramDelegate::rsrInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("RSR[1]=DISABLE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        programView->updateView(true,true);

        qDebug() << "rsr Instruction";
    }
}

void ProgramDelegate::visionInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("RUNVISION[0]; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "vision Instruction";
    }
}

void ProgramDelegate::otherNextMenuForwardPageSlot()
{
//    programView->otherMenu2->close();
//    programView->otherMenu1->show();

    programView->currentMenuIndex = EM_MENUINDEX_OTHERMENU;
    programView->updateView(false,true);
}

void ProgramDelegate::otherNextMenuNextPageSlot()
{
    qDebug() << "other menu Next Page Slot!";
}

void ProgramDelegate::addloadmapinstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("LOAD_MAP test.yaml,JMP LB[1]  ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "MUSIC Instruction";
    }

}
void ProgramDelegate::addCheckBatteryInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("CHECK_BATTERY 30,LBL[1]  ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Check_Battery Instruction";
    }

}
void ProgramDelegate::addWaitCommandInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("WAIT_COMMAND R[1] ,TIMEOUT 5, JMP LBL[1] ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Add WAIT_COMMAND Instruction";
    }
}

void ProgramDelegate::addRobotMoveInstruction_Slot()
{
    // 添加默认机械手控制指令
    if(!instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

//        QString instructionStr1 = tr("TCP_START ");
//        instructionStr1 += tr("127.0.0.1") + ",";
//        instructionStr1 += tr("5050") + "," +  tr("CLIENT") + ",";
//        instructionStr1 += tr("JMP ") + tr("LB") + "[1] ";
//        instructionStr1 += tr(" //");
        QString instruction2 = tr("ROBOT_MOVE IP[127.0.0.1],PORT[5050],SERVER,SEND[SendParameter],WAIT[WaitParameter],TIMEOUT 5, JMP LBL[1] ") + "//";
//        currentProgram.insert(programView->currentLineIndex, instructionStr1);
//        programView->currentLineIndex ++;
        currentProgram.insert(programView->currentLineIndex, instruction2);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Add ROBOT_MOVE Instruction";
    }

}

void ProgramDelegate::addRollerInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("ROLLER General,P,10,JMP LB[1]  // ");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Roller Instruction";
    }
}
void ProgramDelegate::musicInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("MUSIC demo.mp3,循环,100  ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "MUSIC Instruction";
    }
}

void ProgramDelegate::chargingInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("CHARGING CAPARITY,100   //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "CHARGING Instruction";
    }
}

void ProgramDelegate::liftMechanismInstructionSlot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("LIFT General,RISE,10,JMP LB[1]  //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "LIFT Mechanism Instruction";
    }
}

void ProgramDelegate::showLaserCameraMenu_slot()
{
    programView->currentMenuIndex = EM_MENUINDEX_LASERCAMERA;
    programView->updateView(false,true);
}

void ProgramDelegate::laserCameraMenuForwardPage_slot()
{
    programView->currentMenuIndex = EM_MENUINDEX_WELDMENU;
    programView->updateView(false,true);
}

void ProgramDelegate::stampForwardPageSlot()
{
    qDebug() << "stamp menu forward";

    programView->currentMenuIndex = EM_MENUINDEX_INSTRUCTIONMENU_ALL;
    programView->updateView(false,true);
}

void ProgramDelegate::stampNextPageSlot()
{
    //qDebug() << "stamp menu next";
}

void ProgramDelegate::getInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("DJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::getWaitInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("DWJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::getAboveInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("DTJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::getEndInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("DDJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::putInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("FJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::putWaitInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("FWJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::putAboveInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("FTJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::putEndInstructionSlot()
{
    if(! instructionIsArc())
    {
        recordPointInsert(maxUsedPointIndex);
        //
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString index = QString::number(maxUsedPointIndex);
        QString instruction;

        instruction = tr("FDJ P[") + index + tr("] 100% FINE; ") + "//";

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;

        maxUsedPointIndex++;
        programView->updateView(true,true);
    }
}

void ProgramDelegate::addWeldStartInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Weld Start[0,0]; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Weld Start Instruction";
    }
}

//新指令20191130 ZHUHT
void ProgramDelegate::addWeldEndInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Weld End[0,0]; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Weld End Instruction";
    }
}
void ProgramDelegate::addWeaveInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Weave [0]; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Weave Instruction";
    }
}
void ProgramDelegate::addWeaveEndInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Weave End; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Weave End Instruction";
    }
}

void ProgramDelegate::addTrackWeldTastInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Track Weld TAST [0]; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Track TAST Instruction";
    }
}

void ProgramDelegate::addWatchDIInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Watch DI[0]=ON 0 sec DO[0]=OFF; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "WatchDI Instruction";
    }
}

void ProgramDelegate::addLaserCameraTrackIns_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("LASERCAMERA_TRACK ON;//");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "addLaserCameraTrackIns_slot";
    }
}

void ProgramDelegate::addLaserCameraFetchPointIns_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("RECORD_LASERCAMERA PR[1];//");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "addLaserCameraFetchPointIns_slot";
    }
}

void ProgramDelegate::addLaserCameraControlIns_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("LASERCAMERA_CTRL ON JOB[1];//");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "addLaserCameraControlIns_slot";
    }
}

void ProgramDelegate::addLaserScan_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("LASERSCAN START; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "addLaserScan_slot";
    }
}

void ProgramDelegate::addLaserScanEnd_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("LASERSCAN END; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "addLaserScanEnd_slot";
    }
}

void ProgramDelegate::addBufferMove_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("BUFFERMOVE 5mm/sec CONST; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "addBufferMove_slot";
    }
}



void ProgramDelegate::addTrackWeldEndInstruction_slot()
{
    if(! instructionIsArc())
    {
        programView->currentLineIndex = programView->getCurrentLineIndex() + 1;

        QString instruction = tr("Track Weld End; //");

        currentProgram.insert(programView->currentLineIndex, instruction);
        programView->fileInformation = currentProgram;
        programView->updateView(true,true);

        qDebug() << "Track End Instruction";
    }
}

void ProgramDelegate::getCurrentLineInstructionSlot(int index)
{
    if(index>=0 && index<currentProgram.size())
    {
      programView->currentLineInstruction = currentProgram[index];
    }

}

void ProgramDelegate::saveInstructionSlot(QString instruction)
{
    //文件已写入,此处为提示控制器更新,因为码垛属性的修改是文件内部的修改
    //在指令上无法体现的,因为外部点击保存并没有效果,需要提前通知控制器修改
//    QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
//    qDebug()<<"md5:"<<md5;
//    emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);
    programView->isProgramFileSaved = false;//2017.04.24改,如果点击属性内的保存,就需要外面保存一次

    //更新ui
    if(programView->getCurrentLineIndex() >= 0)
    {
        currentProgram[programView->getCurrentLineIndex()] = instruction;
        programView->fileInformation = currentProgram;
    }

    programView->instructionListFlag = 0;

    programView->editInstructionViewShowOrHide();
    programView->updateView(true,true);
}

void ProgramDelegate::openInstructionEditViewSlot()
{
    getFileAddress = fileData.currentRobotFileAddress+"program/";


    if(programView->getCurrentLineIndex() >= 0)
    {
        transferProgramTextToStructData();
    }
}

void ProgramDelegate::changeLanguageSlot(int language)
{
    if(1 == language)
    {
        translator.load("/agvwork/AgvHmi/baseBag/hmiProject/language/programDelEnglishLan.qm");
        qApp->installTranslator(&translator);
    }
    else
    {
        qApp->removeTranslator(&translator);
    }

    programView->changeLanguage(language);
    //各指令界面语言切换
    programView->motionInstructionView->changeLanguage(language);
    programView->motionInstructionDelegate->changeLanguage(language);
    programView->ifInstructionView->changeLanguage(language);
    programView->labelJmpView->changeLanguage(language);
    programView->waitInstructionView->changeLanguage(language);
    programView->forInstructionView->changeLanguage(language);
    programView->registerInstructionView->changeLanguage(language);
    programView->selectInstructionView->changeLanguage(language);
    programView->skipConditionView->changeLanguage(language);
    programView->outputInstructionView->changeLanguage(language);
    programView->coordinateInstructionView->changeLanguage(language);
    programView->otherInstructionView->changeLanguage(language);
    programView->palletInstructionView->changeLanguage(language);
    programView->palletInstructionDelegate->changeLanguage(language);

/*******************************************************************************
 * 修改人:           hualei
 * 修改时间:   (1)  2018-06-26
 *             (2)  2018-07-10
 *             (3)  2018-07-30
 *             (4)  2018-08-01
 *
 * 修改内容:    1-  添加 MOVE_MAG(磁导航) / MOVE_FREE(自由导航) 指令界面语言切换
 *              2-  添加 MODBUS 总线指令界面语言切换
 *              3-  添加 SET_ODOM 重置里程计指令界面语言切换
 *              4-  添加 TCP 以太网通信指令界面语言切换
 *
 * ****************************************************************************/
    programView->moveMagInstructionView->changeLanguage(language);
    programView->moveFreeInstructionView->changeLanguage(language);

    programView->modbusStartInstructionView->changeLanguage(language);
    programView->modbusReadInstructionView->changeLanguage(language);
    programView->modbusWriteInstructionView->changeLanguage(language);
    programView->odometryInstructionView->changeLanguage(language);

    programView->tcpStartInstructionView->changeLanguage(language);
    programView->tcpReadInstructionView->changLanguage(language);
    programView->musicInstructionView->changeLanguage(language);
    programView->chargingInstructionView->changeLanguage(language);
    programView->liftMechanismInstructionView->changeLanguage(language);
}

void ProgramDelegate::changeEditLanguageSlot(int language)
{
    globalData->editLanguage = language;
    programView->editLanguage = language;//编辑界面的语言

    programView->updateView(true,false);//刷新?
}

void ProgramDelegate::showFileInfoChineseSlot()
{
    clock_t start, finish;
    start = clock();

    //2017.05.12 改为fileDate调用(因为runview也要调用)
//    programView->fileInformationChinese = fileData.translateCmdList(ENUM_LAN_CHINESE,programView->fileInformation);
    programView->fileInformationChinese = programLanguageTranslate->translateProgramCmdList(ENUM_LAN_CHINESE,programView->fileInformation);

    finish = clock();
    double duration = (double)(finish - start) / 1000;
    qDebug()<<"------translate--------clock--------"<< duration;
}

void ProgramDelegate::setIsSaveState(bool state)
{
    //载入点后，保存提示为ｆａｌｓｅ.
    programView->isProgramFileSaved = state;
}

void ProgramDelegate::ftpFinishedPutFile(bool result, const QString &message)
{
    if(fileData.ftpOperateNum != EM_FTP_OPERATE_SAVE_FILE)
    {
        return;
    }

    if(result)
    {

        qDebug() << "FTP Put PorgramFile Success.";
        QString md5 = fileData.readProgramToMD5(fileData.currentFileName);
        qDebug()<<"md5:"<<md5;
        emit saveFileAndUpdateCtrlSignal(fileData.currentFileName,md5);
        fileData.ftpOperateNum = EM_FTP_OPERATE_CLOSE;
    }
    else
    {
        fileData.ftpOperateNum = EM_FTP_OPERATE_CLOSE;
        return;
    }
}

void ProgramDelegate::saveCurrentinstruction_Slot()
{
    // 根据当前行指令，更新指令内容
    // 获取界面数据->完成编辑->保存
    if(programView->getCurrentLineIndex() < 0)
    {
        return;
    }

    /********************* MOTION 运动指令 ******************/
    if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_MOTION)
    {
        emit saveMotionInstruction_Signal();
    }
    /********************* IF 条件指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_IF)
    {
        emit saveIfInstruction_Signal();
    }
    /******************** JMP 标签跳转指令 ****************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_LBLJMP)
    {
        emit saveLblJmpInstruction_Signal();
    }
    /********************* WAIT 等待指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_WAIT)
    {
        emit saveWaitInstruction_Signal();
    }
    /********************* FOR 循环指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_FOR)
    {
        emit saveForInstruction_Signal();
    }
    /********************* R 寄存器指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_REGISTER)
    {
        emit saveRegisterInstruction_Signal();
    }
    /********************* SELECT 选择指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_SELECT)
    {
        emit saveSelectInstruction_Signal();
    }
    /********************* SKIP 跳过指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_SKIP)
    {
        emit saveSkipInstruction_Signal();
    }
    /********************* OUTPUT 输出指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_OUTPUT)
    {
        emit saveOutputInstruction_Signal();
    }
    /********************* COORDINATE 坐标指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_COORDINATE)
    {
        emit saveCoordinateInstruction_Signal();
    }
    /********************* OTHER 其他指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_OTHER)
    {
        emit saveOtherInstruction_Signal();
    }
    /********************* PALLET 码垛指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_PALLET)
    {
        emit savePalletInstruction_Signal();
    }
    /********************* PALLET_MOTION 码垛运动指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_PALLET_MOTION)
    {
        emit savePalletMotionInstruction_Signal();
    }
    /********************* VISION 版本指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_VISION)
    {
        emit saveVisionInstruction_Signal();
    }
    /********************* END 结束指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_END)
    {
        //emit saveEndInstruction_Signal();
    }
    /********************* MOVE_MAG 磁导航指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_MOVE_MAG)
    {
        emit saveMoveMagInstruction_Signal();
    }
    /********************* MOVE_FREE 自由导航指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_MOVE_FREE)
    {
        emit saveMoveFreeInstruction_Signal();
    }
    /********************* MODBUS_START modbus总线创建指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_MODBUS_START)
    {
        emit saveModbusStartInstruction_Signal();
    }
    /********************* MODBUS_READ Modbus总线读取指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_MODBUS_READ)
    {
        emit saveModbusReadInstruction_Signal();
    }
    /********************* MODBUS_WRITE Modbus总线发送指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_MODBUS_WRITE)
    {
        emit saveModbusWriteInstruction_Signal();
    }
    /********************* SET_ODOM 重置里程计指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_SET_ODOM)
    {
        emit saveSetOdomInstruction_Signal();
    }
    /********************* TCP_START TCP以太网创建连接指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_TCP_START)
    {
        emit saveTcpStartInstruction_Signal();
    }
    /********************* TCP_READ tcp以太网接收指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_TCP_READ)
    {
        emit saveTcpReadInstruction_Signal();
    }
    /********************* TCP_WRITEtcp以太网发送指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_TCP_WRITE)
    {
        emit saveTcpWriteInstruction_Signal();
    }
    /********************* MUSIC 音乐指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_MUSIC)
    {
        emit saveMusicInstruction_Signal();
    }
    /********************* CHARGING 充电指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_CHARGING)
    {
        emit saveChargingInstruction_Signal();
    }
    /********************* LIFT 升降机构指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_LIFT)
    {
        emit saveLiftInstruction_Signal();
    }
    /********************* LOAD_MAP 加载地图指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_LOAD_MAP)
    {
        emit saveLoadMapInstruction_Signal();
    }
    /********************* CHECK BATTERY 电量检测指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_CHECK_BATTERY)
    {
        emit saveCheckBatteryInstruction_Signal();
    }
    /********************* WaitCommandInstruction *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_WAIT_COMMAND)
    {
        emit saveWaitCommandInstruction_Signal();
    }
    /********************* ROBOT_MOVE 机械手控制指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_ROBOT_MOVE)
    {
        emit saveRobotMoveInstruction_Signal();
    }
    /********************* ROLLER机构指令 *********************/
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_ROLLER)
    {
        emit saveRollerInstruction_Signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_AXIS_MOVE)
    {
        emit saveAxisMoveInstruction_Signal();
    }//拓展新指令增加代码20191122hualei
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_WELD_START)
    {
        emit saveWeldStartInsTruction_signal();
    }
    //新指令20191130 ZHUHT
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_WELD_END)
    {
        emit saveWeldEndInsTruction_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_WEAVE)
    {
        emit saveWeaveInsTruction_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_WEAVE_END)
    {
        emit saveWeaveEndInstruction_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_TRACKWELD_TAST)
    {
        emit saveTrackWeldTastInstruction_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_TRACKWELD_END)
    {
        emit saveTrackWeldEndInstruction_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_WATCHDI)
    {
        emit saveWatchDIInstruction_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_LASERCAMERA_CTRL)
    {
        emit saveLaserCameraControlIns_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_LASERCAMERA_TRACK)
    {
        emit saveLaserCameraTrackIns_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_LASERCAMERA_FETCHP)
    {
        emit saveLaserCameraFetchPointIns_signal();
    }
    else if(programView->editInstructionViewIndex == EM_EDIT_INSTRUCTION_BUFFERMOVE)
    {
        emit saveBufferMoveIns_signal();
    }
}

void ProgramDelegate::setDefaultJMoveSpeed_slot(double speed)
{
    defaultJMoveSpeed=speed;
}

void ProgramDelegate::setDefaultLMoveSpeed_slot(double speed, QString unitType)
{
    defaultLMoveSpeed=speed;
    defaultUniteType=unitType;
}

int ProgramDelegate::transferProgramTextToStructData()
{
    QRegExp rx_currentLine("^\\s*([A-Z_]*)\\-?\\s*([BEXND]{0,3})\\s*\\_?\\d*\\s*([PAL]{0,3})\\s*(.*)");
    programView->currentLineInstruction.indexOf(rx_currentLine);

    QRegExp rxForward("\\s*([A-Z_]*)\\s+(.*)");
    QString forward_instruction;
    if(programView->getCurrentLineIndex() > 0)
    {
        forward_instruction= currentProgram[programView->getCurrentLineIndex() - 1];
        forward_instruction.indexOf(rxForward);
    }

//        qDebug()<<rx.capturedTexts();
    /*********************Motion*********************/
    if((("J" == rx_currentLine.cap(1)) || ("L" == rx_currentLine.cap(1)) || ("C" == rx_currentLine.cap(1))
        || ("A" == rx_currentLine.cap(1)) || ("C" == rxForward.cap(1))) )
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MOTION;
        programView->editInstructionViewShowOrHide();

//            analysisMotionArmInstruction(rx_currentLine,rxForward);
        patMotion(programView->currentLineInstruction,forward_instruction);
        programView->motionInstructionView->updateView();
    }

    /***********************IF************************/
    else if("IF" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_IF;
        programView->editInstructionViewShowOrHide();

        patIf(programView->currentLineInstruction,forward_instruction);

        programView->ifInstructionView->updateView();
        programView->ifInstructionView->callLocation = getFileAddress;//补充 赋予指令属性页面文件浏览器地址


    }
    /**********************LBL************************/
    else if("LBL" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LBLJMP;

        programView->editInstructionViewShowOrHide();

        patLabelInstruction(programView->currentLineInstruction);


        programView->labelJmpView->callLocation = getFileAddress;//补充 赋予指令属性页面文件浏览器地址
        programView->labelJmpView->updateView();
    }
    /**********************JMP************************/
    else if("JMP" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LBLJMP;

        programView->editInstructionViewShowOrHide();

        patJmpInstruction(programView->currentLineInstruction);


        programView->labelJmpView->callLocation = getFileAddress;//补充 赋予指令属性页面文件浏览器地址
        programView->labelJmpView->updateView();
    }
    /**********************END PAUSE ABORT CALL RUN************************/
    else if(("END" == rx_currentLine.cap(1)) || ("PAUSE" == rx_currentLine.cap(1))
            || ("ABORT" == rx_currentLine.cap(1)) || ("CALL" == rx_currentLine.cap(1))
            || ("RUN" == rx_currentLine.cap(1)))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LBLJMP;

        programView->editInstructionViewShowOrHide();

        patEndCallRunInstruction(programView->currentLineInstruction);


        programView->labelJmpView->callLocation = getFileAddress;//补充 赋予指令属性页面文件浏览器地址
        programView->labelJmpView->updateView();
    }

    /**********************WAIT************************/
    else if("WAIT" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_WAIT;

        programView->editInstructionViewShowOrHide();

        patWait(programView->currentLineInstruction);


        programView->waitInstructionView->updateView();
    }

    /***********************FOR************************/
    else if("FOR" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_FOR;

        programView->editInstructionViewShowOrHide();

        patFor(programView->currentLineInstruction);


        programView->forInstructionView->updateView();
    }

    /*********************Register***********************/
    else if(("R" == rx_currentLine.cap(1))|| ("GR" == rx_currentLine.cap(1)) || ("PL" == rx_currentLine.cap(1)))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_REGISTER;

        programView->editInstructionViewShowOrHide();

        patRegisterInstruction(programView->currentLineInstruction);



        programView->registerInstructionView->updateView();
    }

    else if(("PR" == rx_currentLine.cap(1)))
    {


        analysisPrRegisterInstruction();


    }
//    else if((("J" == rx_currentLine.cap(1)) || ("L" == rx_currentLine.cap(1))) && ("PAL" == rx_currentLine.cap(3)))
//    {
//        patPallet_motionInstruction(programView->currentLineInstruction);

//    }
    else if(("DJ" == rx_currentLine.cap(1)) || ("DWJ" == rx_currentLine.cap(1)) || ("DTJ" == rx_currentLine.cap(1)) || ("DDJ" == rx_currentLine.cap(1)) ||
            ("FJ" == rx_currentLine.cap(1)) || ("FWJ" == rx_currentLine.cap(1)) || ("FTJ" == rx_currentLine.cap(1)) || ("FDJ" == rx_currentLine.cap(1)) ||
            ("DL" == rx_currentLine.cap(1)) || ("DWL" == rx_currentLine.cap(1)) || ("DTL" == rx_currentLine.cap(1)) || ("DDL" == rx_currentLine.cap(1)) ||
            ("FL" == rx_currentLine.cap(1)) || ("FWL" == rx_currentLine.cap(1)) || ("FTL" == rx_currentLine.cap(1)) || ("FDL" == rx_currentLine.cap(1)))
    {
        //2017.05.15添加:是与关节结合还是另外
        //qDebug()<<" stamping ";//冲压的指令属性识别

        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MOTION;
        programView->editInstructionViewShowOrHide();

        patPunchInstruction(programView->currentLineInstruction);

        programView->motionInstructionView->updateView();
    }

    /*********************SELECT************************/
    else if("SELECT" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_SELECT;

        programView->editInstructionViewShowOrHide();

        patSelectInstruction(programView->currentLineInstruction);


        programView->selectInstructionView->callLocation = getFileAddress;//补充 赋予指令属性页面文件浏览器地址
        programView->selectInstructionView->updateView();
    }

    /***********************SKIP************************/
    else if("SKIP" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_SKIP;

        programView->editInstructionViewShowOrHide();

        patSkipInstruction(programView->currentLineInstruction);


        programView->skipConditionView->updateView();
    }

    /**********************Output***********************/
    else if("DO" == rx_currentLine.cap(1) || "AO" == rx_currentLine.cap(1))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_OUTPUT;

        programView->editInstructionViewShowOrHide();

        patDoInstruction(programView->currentLineInstruction);


        programView->outputInstructionView->updateView();
    }

    /*********************Coordinate*********************/
    else if(("UTOOL" == rx_currentLine.cap(1)) || ("UFRAME" == rx_currentLine.cap(1)) || ("UTOOL_NUM" == rx_currentLine.cap(1)) || ("UFRAME_NUM" == rx_currentLine.cap(1)))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_COORDINATE;

        programView->editInstructionViewShowOrHide();

        patCoordinateInstruction(programView->currentLineInstruction);


        programView->coordinateInstructionView->updateView();
    }
    /**********************Other1************************/
    else if(("RSR" == rx_currentLine.cap(1)) || ("UALM" == rx_currentLine.cap(1)) || ("TIMER" == rx_currentLine.cap(1)) || ("OVERRIDE" == rx_currentLine.cap(1))
            || ("MESSAGE" == rx_currentLine.cap(1)) || ("JOINT_MAX_SPEED" == rx_currentLine.cap(1)) || ("LINEAR_MAX_SPEED" == rx_currentLine.cap(1)))
    {
        programView->instructionListFlag = 1;
        programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_OTHER;

        programView->editInstructionViewShowOrHide();

        patOther1Instruction(programView->currentLineInstruction);



        programView->otherInstructionView->updateView();
    }
    /******************** MOVE_MAG ***********************/
    else if(("MOVE_MAG" == rx_currentLine.cap(1)))
    {
        analysisMoveMagInstruction();
    }
    /******************* MOVE_FREE *********************/
    else if(("MOVE_FREE" == rx_currentLine.cap(1)))
    {
        analysisMoveFreeInstruction();
    }
    /***********************  MODBUS_START  ***********************/
    else if("MODBUS_START" == rx_currentLine.cap(1))
    {
        analysisModbusStartInstruction();
    }
    /**************** SET_ODOM *****************/
    else if(rx_currentLine.cap(1) == "SET_ODOM")
    {
        analysisSetOdomInstruction();
    }
    /**************** TCP_START *****************/
    else if(rx_currentLine.cap(1) == "TCP_START")
    {
        analysisTcpStartInstruction();
    }
    /****************  TCP_READ *****************/
    else if(rx_currentLine.cap(1) == "TCP_READ")
    {
        analysisTcpReadInstruction();
    }
    /**************** TCP_WRITE *****************/
    else if(rx_currentLine.cap(1) == "TCP_WRITE")
    {
        analysisTcpWriteInstruction();
    }
    /*****************  MUSIC *****************/
    else if(rx_currentLine.cap(1) == "MUSIC")
    {
        analysisMusicInstruction();
    }
    /****************  CHARGING *****************/
    else if(rx_currentLine.cap(1) == "CHARGING")
    {
        analysisChargingInstruction();
    }
    /**************** LIFT **********************/
    else if(rx_currentLine.cap(1) == "LIFT")
    {
        analysisLiftMechanismInstruction();
    }
    /*************** LOAD_MAP *******************/
    else if(rx_currentLine.cap(1) == "LOAD_MAP")
    {
        analysisLoadMapInstruction();
    }
    /*************** WAIT_COMMAND *******************/
    else if(rx_currentLine.cap(1) == "WAIT_COMMAND")
    {
        analysisWaitCommand();
    }
    /*************** ROBOT_MOVE ********************/
    else if(rx_currentLine.cap(1) == "ROBOT_MOVE")
    {
        analysisRobotMove();
    }
    /*************** ROLLER ********************/
    else if(rx_currentLine.cap(1) == "ROLLER")
    {
        analysisRoller();
    }
    else
    {
        //使用通用函数提取指令类型
        int tmpInstructionType=programRegExp->patExtractInstructionType(programView->currentLineInstruction);
        switch(tmpInstructionType)
        {
        case MODBUS_WRITE:
        {
            programView->instructionListFlag = 1;
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MODBUS_WRITE;
            programView->editInstructionViewShowOrHide();


            analysisModbusWriteInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->modbusWriteInstructionView->updateView();
            break;
        }
        case MODBUS_READ:
        {
            programView->instructionListFlag = 1;
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MODBUS_READ;
            programView->editInstructionViewShowOrHide();

            analysisModbusReadInstruction(programView->currentLineInstruction);

            //刷新界面 内容

            programView->modbusReadInstructionView->updateView();
            break;
        }
        case INS_VISION_RUN:
        {
            //指令属性界面标志
            programView->instructionListFlag = 1;
            //页面号
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_VISION;

            //根据 页面号 显示
            programView->editInstructionViewShowOrHide();


            patVisionRunInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->visionInstructionView->updateView();
            break;
        }
        case INS_VISION_TRIGGER:
        {
            //指令属性界面标志
            programView->instructionListFlag = 1;
            //页面号
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_VISION;

            //根据 页面号 显示
            programView->editInstructionViewShowOrHide();


            patVisionTriggerInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->visionInstructionView->updateView();
            break;
        }
        case INS_VISION_GET_DATA:
        {
            //指令属性界面标志
            programView->instructionListFlag = 1;
            //页面号
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_VISION;

            //根据 页面号 显示
            programView->editInstructionViewShowOrHide();


            patVisionGetDataInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->visionInstructionView->updateView();
            break;
        }
        case INS_VISION_CLEAR_DATA:
        {
            //指令属性界面标志
            programView->instructionListFlag = 1;
            //页面号
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_VISION;

            //根据 页面号 显示
            programView->editInstructionViewShowOrHide();


            patVisionClearDataInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->visionInstructionView->updateView();
            break;
        }
        case INS_TRACK_START:
        {
            //指令属性界面标志
            programView->instructionListFlag = 1;
            //页面号
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_VISION;

            //根据 页面号 显示
            programView->editInstructionViewShowOrHide();


            patTrackStartInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->visionInstructionView->updateView();
            break;
        }
        case INS_TRACK_END:
        {
            //指令属性界面标志
            programView->instructionListFlag = 1;
            //页面号
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_VISION;

            //根据 页面号 显示
            programView->editInstructionViewShowOrHide();


            patTrackEndInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->visionInstructionView->updateView();
            break;
        }
        case INS_TRACK_GET_DATA:
        {
            //指令属性界面标志
            programView->instructionListFlag = 1;
            //页面号
            programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_VISION;

            //根据 页面号 显示
            programView->editInstructionViewShowOrHide();


            patTrackGetDataInstruction(programView->currentLineInstruction);

            //刷新界面 内容
            programView->visionInstructionView->updateView();
            break;
        }
        case INS_AXIS_MOVE:
        {

            patAxisMove(programView->currentLineInstruction);

            break;
        }
        case CHECK_BATTERY:
        {

            patCheckBattery(programView->currentLineInstruction);

            break;
        }//拓展新指令增加代码20191122hualei
        case INS_WELD_START:
        {

            patWeldStart(programView->currentLineInstruction);

            break;
        }
            //新指令20191130 ZHUHT
        case INS_WELD_END:
        {

            patWeldEnd(programView->currentLineInstruction);

            break;
        }
        case INS_WEAVE:
        {

            patWeave(programView->currentLineInstruction);

            break;
        }
        case INS_WEAVE_END:
        {

            patWeaveEnd(programView->currentLineInstruction);

            break;
        }
        case INS_TRACKWELD_TAST:
        {

            patTrackWeldTast(programView->currentLineInstruction);

            break;
        }
        case INS_TRACKWELD_END:
        {

            patTrackWeldEnd(programView->currentLineInstruction);

            break;
        }
        case INS_WATCHDI:
        {

            patWatchDI(programView->currentLineInstruction);

            break;
        }
        case INS_LASER_CAMERA_FETCHPOINT:
        {

            patLaserCameraFetchPoint(programView->currentLineInstruction);

            break;
        }
        case INS_LASER_CAMERA_CTRL:
        {

            patLaserCameraControl(programView->currentLineInstruction);

            break;
        }
        case INS_LASER_CAMERA_TRACK:
        {

            patLaserCameraTrack(programView->currentLineInstruction);

            break;
        }
        case INS_PALLET:
        {

            patPalletInstruction(programView->currentLineInstruction);

            break;
        }

        case INS_BUFFER_MOVE:
        {

            patBufferMove(programView->currentLineInstruction);

            break;
        }

        default:
        {
        }

        }
    }
    return 1;
}

int ProgramDelegate::patWeldStart(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_WELD_START;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patWeldStart(programStr,lineOut);
    programView->weldStartInsView->instructionPara=lineOut.weldStartInstruction;

    //刷新界面 内容
    programView->weldStartInsView->updateView();
}

//新指令20191130 ZHUHT
int ProgramDelegate::patWeldEnd(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_WELD_END;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patWeldEnd(programStr,lineOut);
    programView->weldEndInsView->instructionPara=lineOut.weldEndInstruction;

    //刷新界面 内容
    programView->weldEndInsView->updateView();
}
int ProgramDelegate::patWeave(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_WEAVE;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patWeave(programStr,lineOut);
    programView->weaveInsView->instructionPara=lineOut.weaveInstruction;

    //刷新界面 内容
    programView->weaveInsView->updateView();
}
int ProgramDelegate::patWeaveEnd(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_WEAVE_END;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patWeaveEnd(programStr,lineOut);
    programView->weaveEndInsView->instructionPara=lineOut.weaveEndInstruction;

    //刷新界面 内容
    programView->weaveEndInsView->updateView();
}
int ProgramDelegate::patTrackWeldTast(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_TRACKWELD_TAST;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patTrackWeldTast(programStr,lineOut);
    programView->trackWeldTASTInsView->instructionPara=lineOut.trackWeldTastInstruction;

    //刷新界面 内容
    programView->trackWeldTASTInsView->updateView();
}
int ProgramDelegate::patTrackWeldEnd(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_TRACKWELD_END;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patTrackWeldEnd(programStr,lineOut);
    programView->trackWeldEndInsView->instructionPara=lineOut.trackWeldEndInstruction;

    //刷新界面 内容
    programView->trackWeldEndInsView->updateView();
}

int ProgramDelegate::patWatchDI(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_WATCHDI;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patWatchDI(programStr,lineOut);
    programView->watchDIInsView->instructionPara=lineOut.watchDIInstruction;

    //刷新界面 内容
    programView->watchDIInsView->updateView();
}

int ProgramDelegate::patLaserCameraControl(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LASERCAMERA_CTRL;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patLaserCameraControl(programStr,lineOut);
    programView->lasercameraControlInsView->instructionPara=lineOut.laserCameraCtrlInstruction;

    //刷新界面 内容
    programView->lasercameraControlInsView->updateView();
}

int ProgramDelegate::patLaserCameraTrack(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LASERCAMERA_TRACK;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patLaserCameraTrack(programStr,lineOut);
    programView->lasercameraTrackInsView->instructionPara=lineOut.laserCameraTrackInstruction;

    //刷新界面 内容
    programView->lasercameraTrackInsView->updateView();
}

int ProgramDelegate::patLaserCameraFetchPoint(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LASERCAMERA_FETCHP;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patLaserCameraFetchPoint(programStr,lineOut);
    programView->lasercameraFetchPointInsView->instructionPara=lineOut.laserCameraPointFetchInstruction;

    //刷新界面 内容
    programView->lasercameraFetchPointInsView->updateView();
}

int ProgramDelegate::patBufferMove(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_BUFFERMOVE;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patBufferMove(programStr,lineOut);
    *programView->bufferMoveView->bufferIns=lineOut.bufferMoveIns;

    //刷新界面 内容
    programView->bufferMoveView->updateView();
}
int ProgramDelegate::patAxisMove(QString programStr)
{
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_AXIS_MOVE;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patAxisMove(programStr,lineOut);
    programView->axisMoveInstructionView->instructionPara.axisId=lineOut.axisMove.axisId;
    programView->axisMoveInstructionView->instructionPara.rateUnitTypeFlag=lineOut.axisMove.rateUnitTypeFlag;
    programView->axisMoveInstructionView->instructionPara.velocityRatio=lineOut.axisMove.velocityRatio;
    programView->axisMoveInstructionView->instructionPara.targetPosition=lineOut.axisMove.targetPosition;
    programView->axisMoveInstructionView->instructionPara.positionReference=lineOut.axisMove.positionReference;
    programView->axisMoveInstructionView->instructionPara.comment=lineOut.axisMove.comment;


    //刷新界面 内容
    programView->axisMoveInstructionView->updateView();
}

int ProgramDelegate::patMotion(QString programStr, QString forwardLineString)
{
    Line lineOut;
    programRegExp->patMotion(programStr,forwardLineString,lineOut);
    programView->motionInstructionView->moIns=lineOut.motion;
    programView->motionInstructionView->instructionMainFlag=EM_INSTRUCTION_NORMAL;
    programView->motionInstructionView->instructionTypeFlag=lineOut.motion.motionFormat;
    programView->motionInstructionView->positionTypeFlag=lineOut.motion.positionFormat;
    programView->motionInstructionView->positionIndexStr=QString::number(lineOut.motion.p);
    programView->motionInstructionView->instructionRate=lineOut.motion.rate;
    programView->motionInstructionView->rateUnitTypeFlag=lineOut.motion.rateFormat;
    programView->motionInstructionView->fixedPositionTypeFlag=lineOut.motion.cntFormat;
    programView->motionInstructionView->cntValue=lineOut.motion.cnt;
//    programView->motionInstructionView->note=lineOut.motion.;
    switch(lineOut.motion.motionDiType)
    {
    case MOTION_DI_NONE:
        programView->motionInstructionView->isUseDiSkip=0;
        programView->motionInstructionView->diSwitchFlag=0;
        programView->motionInstructionView->labelIndex="";
        break;
    case MOTION_DI_ON:
        programView->motionInstructionView->isUseDiSkip=1;
        programView->motionInstructionView->diSwitchFlag=0;
        programView->motionInstructionView->diIndex=QString::number(lineOut.motion.diValue);
        programView->motionInstructionView->labelIndex=lineOut.motion.lblValue;
        break;
    case MOTION_DI_OFF:
        programView->motionInstructionView->isUseDiSkip=1;
        programView->motionInstructionView->diSwitchFlag=1;
        programView->motionInstructionView->diIndex=QString::number(lineOut.motion.diValue);
        programView->motionInstructionView->labelIndex=lineOut.motion.lblValue;
        break;
    }
//    programView->motionInstructionView->diSwitchFlag=lineOut.motion.;
    programView->motionInstructionView->wjntFlag=lineOut.motion.motionWjntType;
    programView->motionInstructionView->incFlag=lineOut.motion.motionIncType;
//    programView->motionInstructionView->accFlag=lineOut.motion.;
    programView->motionInstructionView->offsetFlag=lineOut.motion.motionOffsetType;
    programView->motionInstructionView->toolOffsetFlag=lineOut.motion.motionToolOffsetType;
    programView->motionInstructionView->evFlag=lineOut.motion.evFlag;
//    programView->motionInstructionView->pthFlag=lineOut.motion.;
    programView->motionInstructionView->accValue=lineOut.motion.acc;
    if(lineOut.motion.acc>0)
    {
        programView->motionInstructionView->accFlag=1;
    }
    else
    {
        programView->motionInstructionView->accFlag=0;
    }
    programView->motionInstructionView->offsetPrIndex=QString::number(lineOut.motion.offsetPrIndex);
//    programView->motionInstructionView->toolOffsetPrIndex=lineOut.motion.;
    programView->motionInstructionView->evValue=lineOut.motion.evValue;
    return 1;

}

int ProgramDelegate::patIf(QString programStr, QString forwardLineString)
{
//    QString pattern("\\s*([IF]{2})\\s+(.*)\\s*,\\s*([JMPCAL]{3,4})\\s+[LB]{0,3}\\s*\\[?\\s*([R]?)\\s*\\[?\\s*(\\d*)\\s*\\]{0,2}\\s*([\\w\\.\\(\\)]*)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    QString pattern;
//    pattern="\\s*([IF]{2})\\s+(.*)\\s*,\\s*([JMPCAL]{3,4})"
//            "\\s+[LB]{0,3}\\s*\\[?\\s*([R]?)"
//            "\\s*\\[?\\s*(\\w*)\\s*\\]{0,2}\\s*([\\w\\.\\(\\)]*)"
//            "\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)";

        pattern="\\s*([IF]{2})\\s+(.*)\\s*,\\s*([JMPCAL]{3,4})"
                "\\s+[LB]{0,3}\\s*\\[?\\s*([R]?)"
                "\\s*(\\[?)\\s*(\\w*)\\s*\\]{0,2}\\s*([\\w\\.\\(\\)]*)"
                "\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)";

    QRegExp rx2(pattern);
    programView->currentLineInstruction.indexOf(rx2);

    programView->ifInstructionView->ifCondition = rx2.cap(2);

    if("JMP" == rx2.cap(3))
    {
        programView->ifInstructionView->dealWithFlag = 0;
        if("R" == rx2.cap(4)&&"[" == rx2.cap(5))
        {
            programView->ifInstructionView->lblDataType = 1;
            programView->ifInstructionView->labelStr = rx2.cap(6);
        }
        else if("R" == rx2.cap(4)&&"[" != rx2.cap(5))
        {
            programView->ifInstructionView->lblDataType = 0;
            programView->ifInstructionView->labelStr = rx2.cap(4)+rx2.cap(5)+rx2.cap(6);
        }
        else
        {
            programView->ifInstructionView->lblDataType = 0;
            programView->ifInstructionView->labelStr = rx2.cap(6);
        }

    }
    else if("CALL" == rx2.cap(3))
    {
        programView->ifInstructionView->dealWithFlag = 1;
        programView->ifInstructionView->callProgram = rx2.cap(6) + rx2.cap(7);
    }
    programView->ifInstructionView->note = rx2.cap(8);

    return 1;

}

int ProgramDelegate::patEndCallRunInstruction(QString programStr)
{

    QString pattern("\\s*([A-Z]*)\\s*[LBL]{0,3}\\s*\\[?\\s*([R]?)\\s*\\[?\\s*(\\d*)\\s*\\]{0,2}\\s*([\\w\\.\\(\\)]*)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    QRegExp rx2(pattern);
    programView->currentLineInstruction.indexOf(rx2);

    QString pattern2("\\s*(RUN|CALL)\\s*(.*)\\s*;(.*)");//2017.04.22补充
    QRegExp rx3(pattern2);
    programView->currentLineInstruction.indexOf(rx3);

    if("END" == rx2.cap(1))
    {
        programView->labelJmpView->selectInstructionFlag = EM_LBLJMP_INSTRUCTION_END;
    }
    else if("PAUSE" == rx2.cap(1))
    {
        programView->labelJmpView->selectInstructionFlag = EM_LBLJMP_INSTRUCTION_PAUSE;
    }
    else if("ABORT" == rx2.cap(1))
    {
        programView->labelJmpView->selectInstructionFlag = EM_LBLJMP_INSTRUCTION_ABORT;
    }
    else if("RUN" == rx3.cap(1))
    {
        programView->labelJmpView->selectInstructionFlag = EM_LBLJMP_INSTRUCTION_RUN;
        programView->labelJmpView->callProgram = rx3.cap(2);
    }
    else if("CALL" == rx3.cap(1))
    {
        programView->labelJmpView->selectInstructionFlag = EM_LBLJMP_INSTRUCTION_CALL;
        programView->labelJmpView->callProgram = rx3.cap(2);
    }
    programView->labelJmpView->note = rx2.cap(5);
    return 1;
}

int ProgramDelegate::patLabelInstruction(QString programStr)
{

    Line lineOut;
    programRegExp->patLabel(programStr,lineOut);

    programView->labelJmpView->selectInstructionFlag = EM_LBLJMP_INSTRUCTION_LBL;
    programView->labelJmpView->lblDataType = 0;

    programView->labelJmpView->labelStr = lineOut.label.labelStr;
    programView->labelJmpView->note = lineOut.label.comment;
    return 1;

}

int ProgramDelegate::patJmpInstruction(QString programStr)
{

    Line lineOut;
    programRegExp->patJump(programStr,lineOut);

    programView->labelJmpView->selectInstructionFlag = EM_LBLJMP_INSTRUCTION_JMP;

    if(DIRECT==lineOut.jump.type)
    {
        programView->labelJmpView->lblDataType = 0;
    }
    else
    {
        programView->labelJmpView->lblDataType = 1;
    }
    programView->labelJmpView->labelStr = lineOut.jump.jumpLabelStr;
    programView->labelJmpView->note = lineOut.jump.comment;

    return 1;
}

int ProgramDelegate::patWait(QString programStr)
{

    QString pattern("\\s*([WAIT]{4})\\s+(\\d*\\.?\\d*)\\s*([sec]{0,3})\\s*([R]?)\\s*(\\[?)\\s*([R]?\\s*\\[?\\s*\\d*)\\s*(\\]?)\\s*(\\]?)\\s*(.*)");
    QString pattern2("\\s*([\\w\\[\\]\\+\\-\\=\\<\\>\\s]*)\\s*\\,?\\s*([TIMEOUT]{0,7})\\s*[LBL]{0,3}\\s*\\[?\\s*([R]?)\\s*\\[?\\s*(\\d*)\\s*\\]{0,2}\\s*(\\]?)\\s*(\\]?)\\s*(.*)");
    QString pattern3("\\s*([R]?)\\s*(\\[?)\\s*([R]?\\[?\\d*\\.?\\d*)\\s*(\\]?)\\s*(\\]?)\\s*([sec]*)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    QRegExp rx2(pattern);
    QRegExp rx3(pattern2);
    QRegExp rx4(pattern3);
    programView->currentLineInstruction.indexOf(rx2);
    rx2.cap(9).indexOf(rx3);
    rx3.cap(7).indexOf(rx4);

    qDebug() << rx3.cap(5);
    qDebug() << rx4.cap(2) ;//<< "11111111";

    if(("sec" == rx2.cap(3)) && ("" != rx2.cap(2)))
    {
        programView->waitInstructionView->waitType = EM_WAIT_INSTRUCTION_TIME;
        programView->waitInstructionView->waitTime = rx2.cap(2).toFloat();
    }
    else if(("R" == rx2.cap(4)) && (("" == rx3.cap(1)) || (" " == rx3.cap(1))))
    {
        programView->waitInstructionView->waitType = EM_WAIT_INSTRUCTION_R;
        programView->waitInstructionView->rIndex = rx2.cap(6) + rx2.cap(8);
    }
    else
    {
        programView->waitInstructionView->waitType = EM_WAIT_INSTRUCTION_CONDITION;
        programView->waitInstructionView->waitCondition = rx2.cap(2) + rx2.cap(3) + rx2.cap(4)
                + rx2.cap(5) + rx2.cap(6) + rx2.cap(7) + rx2.cap(8) + rx3.cap(1);
        if("TIMEOUT" == rx3.cap(2))
        {
            programView->waitInstructionView->timeoutSelectedFlag = 1;
            if("R" == rx3.cap(3))
            {
                programView->waitInstructionView->timeoutLblIndexType = 1;
            }
            else
            {
                programView->waitInstructionView->timeoutLblIndexType = 0;
            }
            programView->waitInstructionView->timeoutLblIndex = rx3.cap(4).toInt();

            if("sec" == rx4.cap(6))
            {
                programView->waitInstructionView->limitWaitTime = rx4.cap(3).toFloat();
                programView->waitInstructionView->limitWaitTimeSelectFlag = 1;
                programView->waitInstructionView->limitWaitTimeType = 0;
            }
            else
            {
                if(("sec" != rx4.cap(6)) && ("R" == rx4.cap(1)))
                {
                    programView->waitInstructionView->limitWaitTimeSelectFlag = 1;
                    programView->waitInstructionView->limitWaitTimeType = 1;
                    programView->waitInstructionView->timeoutRIndex = rx4.cap(3) + rx4.cap(5);
                }
                else
                {
                    programView->waitInstructionView->limitWaitTimeSelectFlag = 0;
                }
            }
        }
        else
        {
            programView->waitInstructionView->timeoutSelectedFlag = 0;
        }
    }
    programView->waitInstructionView->note = rx4.cap(7);
    return 1;
}

int ProgramDelegate::patFor(QString programStr)
{

    QRegExp rx2("\\s*([FOR]{3})\\s*[R]\\s*\\[\\s*([R]?\\s*\\[?\\s*\\d+\\s*\\]?\\s*)\\]\\s*\\=\\s*(.*)");
    QRegExp rx3("\\s*([A]?[R]?)\\s*(\\[?)\\s*([R]?\\s*\\[?\\s*\\d+\\.?\\d*)\\s*(\\]?)\\s*(\\]?)\\s+([TODWN]{2,6})\\s+(.*)");
    QRegExp rx4("\\s*([A]?[R]?)\\s*(\\[?)\\s*([R]?\\s*\\[?\\s*\\d+\\.?\\d*)\\s*(\\]?)\\s*(\\]?)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    programView->currentLineInstruction.indexOf(rx2);
    rx2.cap(3).indexOf(rx3);
    rx3.cap(7).indexOf(rx4);

    if("FOR" == rx2.cap(1))
    {
        programView->forInstructionView->rIndex = rx2.cap(2);

        if("TO" == rx3.cap(6))
        {
            programView->forInstructionView->dealValueTypeFlag = 0;
        }
        else
        {
            programView->forInstructionView->dealValueTypeFlag = 1;
        }

        if("R" == rx3.cap(1))
        {
            programView->forInstructionView->initialValueTypeIndex = EM_FOR_VALUE_TYPE_R;
        }
        else if("AR" == rx3.cap(1))
        {
            programView->forInstructionView->initialValueTypeIndex = EM_FOR_VALUE_TYPE_AR;
        }
        else
        {
            programView->forInstructionView->initialValueTypeIndex = EM_FOR_VALUE_TYPE_CONSTANT;
        }
        programView->forInstructionView->initialData = rx3.cap(3) + rx3.cap(5);

        if("R" == rx4.cap(1))
        {
            programView->forInstructionView->targetValueTypeIndex = EM_FOR_VALUE_TYPE_R;
        }
        else if("AR" == rx4.cap(1))
        {
            programView->forInstructionView->targetValueTypeIndex = EM_FOR_VALUE_TYPE_AR;
        }
        else
        {
            programView->forInstructionView->targetValueTypeIndex = EM_FOR_VALUE_TYPE_CONSTANT;
        }
        programView->forInstructionView->targetData = rx4.cap(3) + rx4.cap(5);

        programView->forInstructionView->note = rx4.cap(6);
    }
    return 1;
}

int ProgramDelegate::patRegisterInstruction(QString programStr)
{
    QString pattern("\\s*([RGPL]{1,2})\\s*(.*)");
    QRegExp rx2(pattern);
    programView->currentLineInstruction.indexOf(rx2);

    if("R" == rx2.cap(1))
    {
        QRegExp rx3("\\s*\\[\\s*([GP]{0,2}\\s*\\d*\\s*\\:?\\s*[R]?\\s*\\[?\\s*\\d*)\\s*(\\])\\s*(\\]?)\\s*\\=\\s*(.*)");
        QRegExp rx4("\\s*([\\w\\[\\]\\+\\-\\*\\/\\,\\s]*)\\s*\\;?\\s*[//]{0,2}\\s*([\\w\\s\\(\\)\\.]*)");
        rx2.cap(2).indexOf(rx3);
        rx3.cap(4).indexOf(rx4);

        programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_R;
        programView->registerInstructionView->rIndex = rx3.cap(1) + rx3.cap(3);
        programView->registerInstructionView->rValue = rx4.cap(1);
        programView->registerInstructionView->note = rx4.cap(2);
    }
    else if("GR" == rx2.cap(1))
    {
        QRegExp rx3("\\s*\\[\\s*([GP]{0,2}\\s*\\d*\\s*\\:?\\s*[R]?\\s*\\[?\\s*\\d*)\\s*(\\])\\s*(\\]?)\\s*\\=\\s*(.*)");
        QRegExp rx4("\\s*([\\w\\[\\]\\+\\-\\*\\/\\,\\s]*)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
        rx2.cap(2).indexOf(rx3);
        rx3.cap(4).indexOf(rx4);

        programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_GR;
        programView->registerInstructionView->gRIndex = rx3.cap(1) + rx3.cap(3);
        programView->registerInstructionView->gRValue = rx4.cap(1);
        programView->registerInstructionView->note = rx4.cap(2);
    }
    else if("PL" == rx2.cap(1))
    {
        QRegExp rx3("\\s*\\[\\s*([GP]{0,2}\\s*\\d*\\s*\\:?\\s*[R]?\\s*\\[?\\s*\\d*)\\s*(\\])\\s*(\\]?)\\s*\\=\\s*(.*)");
        QRegExp rx4("\\s*\\[\\s*(\\*?\\w*\\s*\\[?\\d*\\.?\\d*\\]?)\\s*\\,\\s*(\\*?\\w*\\s*\\[?\\d*\\.?\\d*\\]?)\\s*\\,\\s*(.*)");
        QRegExp rx5("\\s*(\\*?\\w*\\s*\\[?\\d*\\.?\\d*\\]?)\\s*\\]\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
        rx2.cap(2).indexOf(rx3);
        rx3.cap(4).indexOf(rx4);
        rx4.cap(3).indexOf(rx5);

        programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_PL;
        programView->registerInstructionView->pLIndex = rx3.cap(1) + rx3.cap(3);
        programView->registerInstructionView->plElement1 = rx4.cap(1);
        programView->registerInstructionView->plElement2 = rx4.cap(2);
        programView->registerInstructionView->plElement3 = rx5.cap(1);

        programView->registerInstructionView->note = rx5.cap(2);
    }
    return 1;
}

int ProgramDelegate::patPalletInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patPal(programStr,lineOut);
    if(0==lineOut.palInstruct.isStartSet)
    {
        return 0;
    }
    //指令属性界面标志
    programView->instructionListFlag = 1;
    //页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_PALLET;

    //根据 页面号 显示
    programView->editInstructionViewShowOrHide();


    programView->palletInstructionView->palIns=lineOut.palInstruct;

    //刷新界面 内容
    programView->palletInstructionView->updateView();

    return 1;
}


int ProgramDelegate::patPunchInstruction(QString programStr)
{
    qDebug()<<"patPunchInstruction:not support";
//    QRegExp rx_currentLine("^\\s*([A-Z_]*)\\-?\\s*([BEXND]{0,3})\\s*\\_?\\d*\\s*([PAL]{0,3})\\s*(.*)");
//    programStr.indexOf(rx_currentLine);

//    QString pattern("\\s*(\\w?\\w[J]?[L]?)\\s*(P)\\s*\\[\\s*(R?\\[?\\d+\\]?)\\s*\\]\\s*(\\d+\\.?\\d?)\\s*(%)\\s*(FINE)\\s*(.*)");
//    QRegExp rx2(pattern);
//    QString pattern2("\\s*,?\\s*([DI]{0,2})\\s*\\[(\\d+)\\]\\s*=?=?\\s*([ONF]{0,3})\\s*;\\s*//(.*)");
//    QRegExp rx3(pattern2);

//    programView->currentLineInstruction.indexOf(rx2);
//    rx2.cap(7).indexOf(rx3);

//    programView->motionInstructionView->instructionMainFlag = EM_INSTRUCTION_STAMP;//2017.05.16补充
//    if("FJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_F;
//    }
//    else if("FWJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_FW;
//    }
//    else if("FTJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_FT;
//    }
//    else if("FDJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_FD;
//    }
//    else if("DDJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_DD;
//    }
//    else if("DJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_D;
//    }
//    else if("DWJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_DW;
//    }
//    else if("DTJ" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_J;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_DT;
//    }

//    else if("FL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_F;
//    }
//    else if("FWL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_FW;
//    }
//    else if("FTL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_FT;
//    }
//    else if("FDL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_FD;
//    }
//    else if("DDL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_DD;
//    }
//    else if("DL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_D;
//    }
//    else if("DWL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_DW;
//    }
//    else if("DTL" == rx_currentLine.cap(1))
//    {
//        programView->motionInstructionView->instructionTypeFlag = E_MOTION_L;
//        programView->motionInstructionView->instructionStampTypeFlag = EM_INSTRUCTION_TYPE_DT;
//    }

//    programView->motionInstructionView->positionTypeFlag = 0;

//    programView->motionInstructionView->positionIndex = rx2.cap(3);

//    programView->motionInstructionView->instructionRate = rx2.cap(4).toFloat();

//    programView->motionInstructionView->rateUnitTypeFlag = E_RATE_PERCENT;

//    programView->motionInstructionView->fixedPositionTypeFlag = 0;

//    if("DI" == rx3.cap(1))
//    {
//        programView->motionInstructionView->isUseDiSkip = 1;
//        programView->motionInstructionView->diIndex = rx3.cap(2);
//        if("ON" == rx3.cap(3))
//        {
//            programView->motionInstructionView->diSwitchFlag = 0;
//        }
//        else
//        {
//            programView->motionInstructionView->diSwitchFlag = 1;
//        }
//    }
//    else
//    {
//        programView->motionInstructionView->isUseDiSkip = 0;
//    }

//    programView->motionInstructionView->note = rx3.cap(4);
}

int ProgramDelegate::patSelectInstruction(QString programStr)
{

    QString pattern("\\s*([SELECT]{6})\\s*[R]\\s*\\[\\s*([R]?\\s*\\[?\\s*\\d+)\\s*\\]\\s*(\\]?)\\s*\\=\\s*([R]?\\s*\\[?\\s*\\d+\\s*\\]?)\\s*\\,\\s*(.*)");
    QString pattern2("\\s*([JMPCAL]{3,4})\\s+[LB]{0,3}\\s*(\\[?)\\s*([R]?\\(?\\)?\\s*\\[?\\s*\\d*)\\s*(\\]?)\\s*(\\]?)\\s*([\\(\\)\\]\\w\\.]*)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    QRegExp rx2(pattern);
    QRegExp rx3(pattern2);
    programView->currentLineInstruction.indexOf(rx2);
    rx2.cap(5).indexOf(rx3);

    programView->selectInstructionView->rIndex = rx2.cap(2) + rx2.cap(3);
    programView->selectInstructionView->rValue = rx2.cap(4);
    if("JMP" == rx3.cap(1))
    {
        programView->selectInstructionView->dealWithType = 0;
        programView->selectInstructionView->lblIndex = rx3.cap(3) + rx3.cap(5);
    }
    else
    {
        programView->selectInstructionView->dealWithType = 1;
        programView->selectInstructionView->callProgram = rx3.cap(3) + rx3.cap(5) + rx3.cap(6);
    }

    programView->selectInstructionView->note = rx3.cap(7);
    return 1;
}

int ProgramDelegate::patSkipInstruction(QString programStr)
{

    QRegExp rx_currentLine("^\\s*([A-Z_]*)\\-?\\s*([BEXND]{0,3})\\s*\\_?\\d*\\s*([PAL]{0,3})\\s*(.*)");
    programStr.indexOf(rx_currentLine);

    QString pattern2("\\s*([SKIP]{4})\\s+[CONDITION]{9}\\s+([\\w\\[\\]\\+\\-\\>\\<\\=]*)\\s*\\;?\\s*\\//?\\s*([\\w\\s]*)");
    QString pattern3("\\s*([SkipLB,]{8})\\s*\\[\\s*([R]?\\s*\\[?\\s*\\d*)\\s*\\]\\s*(\\]?)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    QRegExp rx2(pattern2);
    QRegExp rx3(pattern3);

    if("SKIP,LBL" == rx_currentLine.cap(1))
    {
        programView->currentLineInstruction.indexOf(rx3);
        programView->skipConditionView->conditionTailFlag = 1;
        programView->skipConditionView->lblIndex = rx3.cap(2) + rx3.cap(3);
    }
    else
    {
        programView->currentLineInstruction.indexOf(rx2);
        programView->skipConditionView->conditionHeadFlag = 1;
        programView->skipConditionView->condition = rx2.cap(2);
    }
    return 1;
}

int ProgramDelegate::patDoInstruction(QString programStr)
{

    QString pattern("\\s*([DAO]{2})\\s*(\\[?)\\s*([R]?\\s*\\[?\\s*\\d+)\\s*(\\]?)\\s*(\\]?)\\s*\\=\\s*([ONFPULSER]{0,5})\\s*(.*)");
    QString pattern2("\\s*\\,?\\s*(\\[?)\\s*([R]?\\s*\\[?\\s*\\d*\\s*\\.?\\s*\\d*)\\s*(\\]?)\\s*(\\]?)\\s*([sec]{0,3})\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    QRegExp rx2(pattern);
    QRegExp rx3(pattern2);
    programView->currentLineInstruction.indexOf(rx2);
    rx2.cap(7).indexOf(rx3);

    programView->outputInstructionView->index = rx2.cap(3) + rx2.cap(5);
    if("DO" == rx2.cap(1))
    {
        programView->outputInstructionView->outputType = 0;
        if(("ON" == rx2.cap(6)) || ("OFF" == rx2.cap(6)))
        {
            programView->outputInstructionView->selectDoFlag = EM_OUTPUT_TYPE_SWITCH;
            if("ON" == rx2.cap(6))
            {
                programView->outputInstructionView->switchType = 0;
            }
            else
            {
                programView->outputInstructionView->switchType = 1;
            }
        }
        else if("PULSE" == rx2.cap(6))
        {
            programView->outputInstructionView->selectDoFlag = EM_OUTPUT_TYPE_PULSE;
            programView->outputInstructionView->pulseTime = rx3.cap(2).toFloat();
        }
        else if("R" == rx2.cap(6))
        {
            programView->outputInstructionView->selectDoFlag = EM_OUTPUT_TYPE_REGISTER;
            programView->outputInstructionView->rIndex = rx3.cap(2) + rx3.cap(4);
        }
    }
    else if("AO" == rx2.cap(1))
    {
        programView->outputInstructionView->outputType = 1;
        programView->outputInstructionView->aoValue = rx3.cap(2).toFloat();
    }
    programView->outputInstructionView->note = rx3.cap(6);
    return 1;
}

int ProgramDelegate::patCoordinateInstruction(QString programStr)
{

    QString pattern("\\s*([U][A-Z_]{4,9})\\s*\\[?\\s*([GP]{0,2}\\s*\\d*\\s*\\:?\\s*\\d*)\\s*\\]?\\s*\\=\\s*(.*)");
    QString pattern2("\\s*([P]?[R]?)\\s*(\\[?)\\s*([GP]{0,2}\\s*\\d*\\s*\\:?\\s*[R]?\\s*\\[?\\s*\\d*)\\s*(\\]?)\\s*(\\]?)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
    QRegExp rx2(pattern);
    QRegExp rx3(pattern2);
    programView->currentLineInstruction.indexOf(rx2);
    rx2.cap(3).indexOf(rx3);

    if("UTOOL" == rx2.cap(1))
    {
        programView->coordinateInstructionView->selectType = EM_COORDINATE_SETTING_TOOL;
        programView->coordinateInstructionView->setToolIndex = rx2.cap(2).toInt();
        programView->coordinateInstructionView->toolPRValue = rx3.cap(3).toInt();
    }
    else if("UFRAME" == rx2.cap(1))
    {
        programView->coordinateInstructionView->selectType = EM_COORDINATE_SETTING_FRAME;
        programView->coordinateInstructionView->setFrameIndex = rx2.cap(2).toInt();
        programView->coordinateInstructionView->framePRValue = rx3.cap(3).toInt();
    }
    else if("UTOOL_NUM" == rx2.cap(1))
    {
        programView->coordinateInstructionView->selectType = EM_COORDINATE_SETTING_TOOL_NUM;
        programView->coordinateInstructionView->selectToolValue = rx3.cap(1) + rx3.cap(2) + rx3.cap(3) + rx3.cap(4) + rx3.cap(5);
    }
    else if("UFRAME_NUM" == rx2.cap(1))
    {
        programView->coordinateInstructionView->selectType = EM_COORDINATE_SETTING_FRAME_NUM;
        programView->coordinateInstructionView->selectFrameValue = rx3.cap(1) + rx3.cap(2) + rx3.cap(3) + rx3.cap(4) + rx3.cap(5);
    }
    programView->coordinateInstructionView->note = rx3.cap(6);
    return 1;
}

int ProgramDelegate::patOther1Instruction(QString programStr)
{
    QString pattern("\\s*([A-Z_]*)\\s*\\[?\\s*(\\d*)\\s*\\]?\\s*\\=?\\s*([R]?)\\s*([[]?)\\s*([\\w\\*\\.\\@]*)\\s*([\\w\\[\\]\\+\\s]*)\\s*\\%?\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");

    QRegExp rx2(pattern);
    programView->currentLineInstruction.indexOf(rx2);

    //qDebug() << rx2.cap(3) << rx2.cap(4) << rx2.cap(5) << rx2.cap(6);

    if("RSR" == rx2.cap(1))
    {
        programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_RSR;
        programView->otherInstructionView->rsrIndex = rx2.cap(2).toInt();
        if("ENABLE" == rx2.cap(5))
        {
            programView->otherInstructionView->rsrValueType = 0;
        }
        else if("DISABLE" == rx2.cap(5))
        {
            programView->otherInstructionView->rsrValueType = 1;
        }
    }
    else if("UALM" == rx2.cap(1))
    {
        programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_UALM;

        QString pattern("\\s*UALM\\s*\\[(.*)\\]\\s*(.*)");
        QRegExp rx3(pattern);
        programView->currentLineInstruction.indexOf(rx3);

        programView->otherInstructionView->ualmInfo = rx3.cap(1);
    }
    else if("TIMER" == rx2.cap(1))
    {
        programView->otherInstructionView->timerIndex = rx2.cap(2).toInt();
        if("START" == rx2.cap(5))
        {
            qDebug() << rx2.cap(5);
            programView->otherInstructionView->timerStatusType = 0;
            programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_TIMER;
        }
        else if("STOP" == rx2.cap(5))
        {
            qDebug() << rx2.cap(5);
            programView->otherInstructionView->timerStatusType = 1;
            programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_TIMER;
        }
        else if(("ESET" == rx2.cap(5)) || ("RESET" == rx2.cap(5)))
        {
            qDebug() << rx2.cap(5);
            programView->otherInstructionView->timerStatusType = 2;
            programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_TIMER;
        }
        else
        {
            programView->otherInstructionView->timerValue = rx2.cap(3) + rx2.cap(4) + rx2.cap(5) + rx2.cap(6);
            programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_TIMER_2;
        }
    }
    else if("OVERRIDE" == rx2.cap(1))
    {
        programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_OVERRIDE;
        programView->otherInstructionView->overrideValue = rx2.cap(5).toInt();
    }
    else if("MESSAGE" == rx2.cap(1))
    {
        programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_MESSAGE;

        QString pattern("\\s*MESSAGE\\s*\\[(.*)\\]\\s*(.*)");
        QRegExp rx3(pattern);
        programView->currentLineInstruction.indexOf(rx3);
        programView->otherInstructionView->message = rx3.cap(1);
    }
    else if("JOINT_MAX_SPEED" == rx2.cap(1))
    {
        programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_J_MAX_SPEED;
        programView->otherInstructionView->jIndex = rx2.cap(2).toInt();
        programView->otherInstructionView->jMaxSpeedValue = rx2.cap(3) + rx2.cap(4) + rx2.cap(5) + rx2.cap(6);
    }
    else if("LINEAR_MAX_SPEED" == rx2.cap(1))
    {
        programView->otherInstructionView->selectInstructionType = EM_OTHER_INSTRUCTION_L_MAX_SPEED;
        programView->otherInstructionView->lMaxSpeedValue = rx2.cap(3) + rx2.cap(4) + rx2.cap(5) + rx2.cap(6);
    }
    programView->otherInstructionView->note = rx2.cap(7);
    return 1;
}

int ProgramDelegate::patVisionRunInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patVisionRun(programStr,lineOut);

    programView->visionInstructionView->note = lineOut.visionRunInstruction.comment;
    programView->visionInstructionView->isVisionCommandFlag=true;
    programView->visionInstructionView->visionCommandIndex=E_VISION_COMMAND_TYPE_RUN;
    programView->visionInstructionView->visionIndex= lineOut.visionRunInstruction.visionIndex;
    return 1;
}

int ProgramDelegate::patVisionTriggerInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patVisionTrigger(programStr,lineOut);

    programView->visionInstructionView->note = lineOut.visionTriggerInstruction.comment;
    programView->visionInstructionView->isVisionCommandFlag=true;
    programView->visionInstructionView->visionCommandIndex=E_VISION_COMMAND_TYPE_TRIGGER;
    programView->visionInstructionView->visionIndex= lineOut.visionTriggerInstruction.visionIndex;
    return 1;
}

int ProgramDelegate::patVisionGetDataInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patVisionGetData(programStr,lineOut);

    programView->visionInstructionView->note = lineOut.visionGetDataInstruction.comment;
    programView->visionInstructionView->isVisionCommandFlag=true;
    programView->visionInstructionView->visionCommandIndex=E_VISION_COMMAND_TYPE_GET_DATA;
    programView->visionInstructionView->visionIndex= lineOut.visionGetDataInstruction.visionIndex;
    return 1;
}

int ProgramDelegate::patVisionClearDataInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patVisionClearData(programStr,lineOut);

    programView->visionInstructionView->note = lineOut.visionClearDataInstruction.comment;
    programView->visionInstructionView->isVisionCommandFlag=true;
    programView->visionInstructionView->visionCommandIndex=E_VISION_COMMAND_TYPE_CLEAR_DATA;
    programView->visionInstructionView->visionIndex= lineOut.visionClearDataInstruction.visionIndex;
    return 1;
}

int ProgramDelegate::patTrackStartInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patTrackStart(programStr,lineOut);

    programView->visionInstructionView->note = lineOut.trackStartInstruction.comment;
    programView->visionInstructionView->isVisionCommandFlag=false;
    programView->visionInstructionView->beltCommandIndex=E_TRACK_COMMAND_TYPE_START;
    programView->visionInstructionView->beltIndex= lineOut.trackStartInstruction.beltIndex;
    return 1;
}

int ProgramDelegate::patTrackEndInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patTrackEnd(programStr,lineOut);

    programView->visionInstructionView->note = lineOut.trackEndInstruction.comment;
    programView->visionInstructionView->isVisionCommandFlag=false;
    programView->visionInstructionView->beltCommandIndex=E_TRACK_COMMAND_TYPE_END;
    programView->visionInstructionView->beltIndex= lineOut.trackEndInstruction.beltIndex;
    return 1;
}

int ProgramDelegate::patTrackGetDataInstruction(QString programStr)
{
    Line lineOut;
    programRegExp->patTrackGetData(programStr,lineOut);

    programView->visionInstructionView->note = lineOut.trackGetDataInstruction.comment;
    programView->visionInstructionView->isVisionCommandFlag=false;
    programView->visionInstructionView->beltCommandIndex=E_TRACK_COMMAND_TYPE_GET_DATA;
    programView->visionInstructionView->beltIndex= lineOut.trackGetDataInstruction.beltIndex;
    return 1;
}


void ProgramDelegate::analysisMusicInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MUSIC;
    programView->editInstructionViewShowOrHide();

    qDebug() << "Current Instruction = " << programView->currentLineInstruction;
    QString str_music = QString("%1%2%3%4%5")
            .arg("\\s*(MUSIC)")
            .arg("\\s*([\\s\\S]*)\\s*,")
            .arg("\\s*([1-6]|循环|暂停)\\s*,")
            .arg("\\s*(0|[0-9]{1,2}|100)")
            .arg("\\s*(//)\\s*([\\s\\S]*)");

    QRegExp rxMusic(str_music);
    bool result = rxMusic.exactMatch(programView->currentLineInstruction);
    if(result)
    {
        QString fileName;
        if(rxMusic.cap(2).startsWith(" "))
        {
            fileName = rxMusic.cap(2).remove(QRegExp("\\s"));
            programView->musicInstructionView->musicFileName = fileName;
        }
        else
        {
           programView->musicInstructionView->musicFileName = rxMusic.cap(2);
        }

        if(rxMusic.cap(3) == tr("循环"))
        {
            programView->musicInstructionView->musicPlayTimes = -1;
        }
        else if(rxMusic.cap(3) == tr("暂停"))
        {
            programView->musicInstructionView->musicPlayTimes = 0;
        }
        else
        {
            programView->musicInstructionView->musicPlayTimes = rxMusic.cap(3).toInt();
        }

        qDebug() << "rxMusic.cap(3) == " << rxMusic.cap(3);
        qDebug() << "programView->musicInstructionView->musicPlayTimes :" << programView->musicInstructionView->musicPlayTimes;
        programView->musicInstructionView->musicVolume = rxMusic.cap(4).toInt();
        programView->musicInstructionView->noteStr = rxMusic.cap(6);
        qDebug() << programView->musicInstructionView->musicFileName;

        programView->musicInstructionView->updateView();
    }

}

void ProgramDelegate::analysisChargingInstruction()
{

    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_CHARGING;
    programView->editInstructionViewShowOrHide();

    qDebug() << "Current Instruction = " << programView->currentLineInstruction;

    QString str_charging = QString("%1%2%3%4")
            .arg("CHARGING\\s*")
            .arg("(TIME|CAPARITY|FIRFIN)\\s*,\\s*")
            .arg("((\\d+)|((\\d+),(\\d+)))\\s*")
            .arg("(//)\\s*(.*)");
    QRegExp rxCharging(str_charging);
    if(rxCharging.exactMatch(programView->currentLineInstruction))
    {
//        qDebug() << "1 :" << rxCharging.cap(1);
//        qDebug() << "2 :" << rxCharging.cap(2);
//        qDebug() << "3 :" << rxCharging.cap(3);
//        qDebug() << "4 :" << rxCharging.cap(4);
//        qDebug() << "5 :" << rxCharging.cap(5);
//        qDebug() << "6 :" << rxCharging.cap(6);
//        qDebug() << "7 :" << rxCharging.cap(7);
//        qDebug() << "8 :" << rxCharging.cap(8);

        if(rxCharging.cap(1) == tr("TIME"))
        {
            programView->chargingInstructionView->chargingFinishedType = E_CHARGING_TIME;
            programView->chargingInstructionView->chargingTime = rxCharging.cap(3).toInt();
            programView->chargingInstructionView->chargingCaparity = 0;
        }
        else if(rxCharging.cap(1) == tr("CAPARITY"))
        {
            programView->chargingInstructionView->chargingFinishedType = E_CHARGING_CAPARITY;
            programView->chargingInstructionView->chargingCaparity = rxCharging.cap(3).toInt();
            programView->chargingInstructionView->chargingTime = 0;
        }
        else if(rxCharging.cap(1) == tr("FIRFIN"))
        {
            programView->chargingInstructionView->chargingFinishedType = E_CHARGING_FIRST_FINISHED;
            programView->chargingInstructionView->chargingTime = rxCharging.cap(5).toInt();
            programView->chargingInstructionView->chargingCaparity = rxCharging.cap(6).toInt();
        }

        programView->chargingInstructionView->noteStr = rxCharging.cap(8);

//        qDebug() << "programView->chargingInstructionView->chargingFinishedType = " << programView->chargingInstructionView->chargingFinishedType;
//        qDebug() << "programView->chargingInstructionView->chargingTime =" << programView->chargingInstructionView->chargingTime;
//        qDebug() << "programView->chargingInstructionView->chargingCaparity = " << programView->chargingInstructionView->chargingCaparity;
//        qDebug() << "programView->chargingInstructionView->noteStr = " << programView->chargingInstructionView->noteStr;

        programView->chargingInstructionView->updateView();
    }

}

void ProgramDelegate::analysisLiftMechanismInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LIFT;
    programView->editInstructionViewShowOrHide();

    qDebug() << "Current Instruction :" << programView->currentLineInstruction;

    QString str_LiftMechanism = QString("%1%2%3%4%5%6")
            .arg("(LIFT)\\s*")
            .arg("(General|Heavy),\\s*")
            .arg("(RISE|DOWN|RIMI|DOMI),\\s*")
            .arg("(\\-?\\d+),\\s*")
            .arg("(JMP)\\s*(LB\\[(\\-?\\d+)\\])\\s*")
            .arg("(//)\\s*(.*)");

    QRegExp rxLift(str_LiftMechanism);
    if(rxLift.exactMatch(programView->currentLineInstruction))
    {
//        if(rxLift.cap(2).contains(tr("General")))
//        {
//            programView->liftMechanismInstructionView->mechanismType = E_MECHANISM_GENERAL;
//        }
//        else if(rxLift.cap(2).contains(tr("Heavy")))
//        {
//            programView->liftMechanismInstructionView->mechanismType = E_MECHANISM_HEAVY;
//        }

        if(rxLift.cap(3) == tr("RISE"))
        {
            programView->liftMechanismInstructionView->liftType = E_LIFT_RISE;
        }
        else if(rxLift.cap(3) == tr("DOWN"))
        {
            programView->liftMechanismInstructionView->liftType = E_LIFT_DOWN;
        }
        else if(rxLift.cap(3) == tr("RIMI"))
        {
            programView->liftMechanismInstructionView->liftType = E_LIFT_RISE_MIDDLE;
        }
        else if(rxLift.cap(3) == tr("DOMI"))
        {
            programView->liftMechanismInstructionView->liftType = E_LIFT_DOWN_MIDDLE;
        }
        else
        {
            programView->liftMechanismInstructionView->liftType = E_LIFT_ERROR;
        }

        programView->liftMechanismInstructionView->timeOutValue = rxLift.cap(4).toInt();
        programView->liftMechanismInstructionView->jmpLbValue = rxLift.cap(7).toInt();
        programView->liftMechanismInstructionView->noteStr = rxLift.cap(9);

        programView->liftMechanismInstructionView->updateView();
    }

}

void ProgramDelegate::analysisTcpWriteInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_TCP_WRITE;
    programView->editInstructionViewShowOrHide();

    qDebug() << "Current Instruction = " << programView->currentLineInstruction;
    QString str_tcpWrite = QString("%1%2%3%4%5%6%7%8")
                    .arg("\\s*(TCP_WRITE)\\s*")
                    .arg("((R\\[(\\-?\\d+)\\])|(\\-?\\d+))\\s*")
                    .arg("((,R\\[(\\-?\\d+)\\]\\s*,)|(,))\\s*")
                    .arg("((\\-?\\d+)\\.(\\-?\\d+)\\.(\\-?\\d+)\\.(\\-?\\d+))\\s*,\\s*")
                    .arg("(\\-?\\d+)\\s*,\\s*")
                    .arg("(SERVER|CLIENT)\\s*,\\s*")
                    .arg("(JMP)\\s*(LB\\[(\\-?\\d+)\\])\\s*")
                    .arg("(//)\\s*(.*)");
    QRegExp rx_tcpWrite(str_tcpWrite);

    bool match = rx_tcpWrite.exactMatch(programView->currentLineInstruction);
    if(match)
    {
//                qDebug() << "rx_tcpWrite.cap(1) = " << rx_tcpWrite.cap(1);
//                qDebug() << "rx_tcpWrite.cap(2) = " << rx_tcpWrite.cap(2);
//                qDebug() << "rx_tcpWrite.cap(3) = " << rx_tcpWrite.cap(3);
//                qDebug() << "rx_tcpWrite.cap(4) = " << rx_tcpWrite.cap(4);
//                qDebug() << "rx_tcpWrite.cap(5) = " << rx_tcpWrite.cap(5);
//                qDebug() << "rx_tcpWrite.cap(6) = " << rx_tcpWrite.cap(6);
//                qDebug() << "rx_tcpWrite.cap(7) = " << rx_tcpWrite.cap(7);
//                qDebug() << "rx_tcpWrite.cap(8) = " << rx_tcpWrite.cap(8);
//                qDebug() << "rx_tcpWrite.cap(9) = " << rx_tcpWrite.cap(9);
//                qDebug() << "rx_tcpWrite.cap(10) = " << rx_tcpWrite.cap(10);
//                qDebug() << "rx_tcpWrite.cap(11) = " << rx_tcpWrite.cap(11);
//                qDebug() << "rx_tcpWrite.cap(12) = " << rx_tcpWrite.cap(12);
//                qDebug() << "rx_tcpWrite.cap(13) = " << rx_tcpWrite.cap(13);
//                qDebug() << "rx_tcpWrite.cap(14) = " << rx_tcpWrite.cap(14);
//                qDebug() << "rx_tcpWrite.cap(15) = " << rx_tcpWrite.cap(15);
//                qDebug() << "rx_tcpWrite.cap(16) = " << rx_tcpWrite.cap(16);
//                qDebug() << "rx_tcpWrite.cap(17) = " << rx_tcpWrite.cap(17);
//                qDebug() << "rx_tcpWrite.cap(18) = " << rx_tcpWrite.cap(18);
//                qDebug() << "rx_tcpWrite.cap(19) = " << rx_tcpWrite.cap(19);
//                qDebug() << "rx_tcpWrite.cap(20) = " << rx_tcpWrite.cap(20);
//                qDebug() << "rx_tcpWrite.cap(21) = " << rx_tcpWrite.cap(21);

        if(rx_tcpWrite.cap(2).contains("R"))
        {
            programView->tcpWriteInstructionView->tcpWriteType = E_TCP_WRITE_TYPE_REGISTER;
            programView->tcpWriteInstructionView->tcpWriteRegBegAddress = rx_tcpWrite.cap(4).toInt();
            programView->tcpWriteInstructionView->regLengthValue = rx_tcpWrite.cap(8).toInt();
            programView->tcpWriteInstructionView->tcpWriteConstValue = "0";
        }
        else
        {
            programView->tcpWriteInstructionView->tcpWriteType = E_TCP_WRITE_TYPE_CONST;
            programView->tcpWriteInstructionView->tcpWriteConstValue = rx_tcpWrite.cap(2);
            programView->tcpWriteInstructionView->tcpWriteRegBegAddress = 1;
            programView->tcpWriteInstructionView->regLengthValue = 1;
        }

        if(rx_tcpWrite.cap(16) == tr("SERVER"))
        {
            programView->tcpWriteInstructionView->tcpWriteClientIPVec[0] = rx_tcpWrite.cap(11).toInt();
            programView->tcpWriteInstructionView->tcpWriteClientIPVec[1] = rx_tcpWrite.cap(12).toInt();
            programView->tcpWriteInstructionView->tcpWriteClientIPVec[2] = rx_tcpWrite.cap(13).toInt();
            programView->tcpWriteInstructionView->tcpWriteClientIPVec[3] = rx_tcpWrite.cap(14).toInt();
            programView->tcpWriteInstructionView->tcpWriteBusType = E_TCP_WRITE_BUS_SERVER;
        }
        else if(rx_tcpWrite.cap(16) == tr("CLIENT"))
        {
            programView->tcpWriteInstructionView->tcpWriteServerIPVec[0] = rx_tcpWrite.cap(11).toInt();
            programView->tcpWriteInstructionView->tcpWriteServerIPVec[1] = rx_tcpWrite.cap(12).toInt();
            programView->tcpWriteInstructionView->tcpWriteServerIPVec[2] = rx_tcpWrite.cap(13).toInt();
            programView->tcpWriteInstructionView->tcpWriteServerIPVec[3] = rx_tcpWrite.cap(14).toInt();
            programView->tcpWriteInstructionView->tcpWriteBusType = E_TCP_WRITE_BUS_CLIENT;
        }

        programView->tcpWriteInstructionView->tcpWritePort = rx_tcpWrite.cap(15).toInt();
        programView->tcpWriteInstructionView->jmpLBValue = rx_tcpWrite.cap(19).toInt();
        programView->tcpWriteInstructionView->noteStr = rx_tcpWrite.cap(21);

        programView->tcpWriteInstructionView->updateView();

    }
}

void ProgramDelegate::analysisTcpStartInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_TCP_START;
    programView->editInstructionViewShowOrHide();

    qDebug() << "Current InexInstruction = " << programView->currentLineInstruction;

    QString str_tcpStart = QString("%1%2%3%4%5%6")
            .arg("\\s*(TCP_START)\\s*")
            .arg("((\\-?\\d+)\\.(\\-?\\d+)\\.(\\-?\\d+)\\.(\\-?\\d+))\\s*(,)\\s*")
            .arg("(\\-?\\d+)\\s*(,)")
            .arg("(SERVER|CLIENT)\\s*(,)\\s*")
            .arg("(JMP)\\s*(LB\\[(\\-?\\d+)\\])\\s*")
            .arg("(//)\\s*(.*)");

    QRegExp rx_tcpStart(str_tcpStart);
    bool match = rx_tcpStart.exactMatch(programView->currentLineInstruction);
    if(match)
    {
//        qDebug() << "rx_tcpWrite.cap(1) = " << rx_tcpStart.cap(1);
//        qDebug() << "rx_tcpWrite.cap(2) = " << rx_tcpStart.cap(2);
//        qDebug() << "rx_tcpWrite.cap(3) = " << rx_tcpStart.cap(3);
//        qDebug() << "rx_tcpWrite.cap(4) = " << rx_tcpStart.cap(4);
//        qDebug() << "rx_tcpWrite.cap(5) = " << rx_tcpStart.cap(5);
//        qDebug() << "rx_tcpWrite.cap(6) = " << rx_tcpStart.cap(6);
//        qDebug() << "rx_tcpWrite.cap(7) = " << rx_tcpStart.cap(7);
//        qDebug() << "rx_tcpWrite.cap(8) = " << rx_tcpStart.cap(8);
//        qDebug() << "rx_tcpWrite.cap(9) = " << rx_tcpStart.cap(9);
//        qDebug() << "rx_tcpWrite.cap(10) = " << rx_tcpStart.cap(10);
//        qDebug() << "rx_tcpWrite.cap(11) = " << rx_tcpStart.cap(11);
//        qDebug() << "rx_tcpWrite.cap(12) = " << rx_tcpStart.cap(12);
//        qDebug() << "rx_tcpWrite.cap(13) = " << rx_tcpStart.cap(13);
//        qDebug() << "rx_tcpWrite.cap(14) = " << rx_tcpStart.cap(14);
//        qDebug() << "rx_tcpWrite.cap(15) = " << rx_tcpStart.cap(15);
//        qDebug() << "rx_tcpWrite.cap(16) = " << rx_tcpStart.cap(16);
//        qDebug() << "rx_tcpWrite.cap(17) = " << rx_tcpStart.cap(17);
//        qDebug() << "rx_tcpWrite.cap(18) = " << rx_tcpStart.cap(18);
//        qDebug() << "rx_tcpWrite.cap(19) = " << rx_tcpStart.cap(19);
//        qDebug() << "rx_tcpWrite.cap(20) = " << rx_tcpStart.cap(20);
//        qDebug() << "rx_tcpWrite.cap(21) = " << rx_tcpStart.cap(21);

        programView->tcpStartInstructionView->tcpStartPort = rx_tcpStart.cap(8).toInt();

        if(rx_tcpStart.cap(10) == "SERVER")
        {
            programView->tcpStartInstructionView->tcpStartType = E_TCP_START_SERVER;

            programView->tcpStartInstructionView->tcpStartClientIpVec[0] = rx_tcpStart.cap(3).toInt();
            programView->tcpStartInstructionView->tcpStartClientIpVec[1] = rx_tcpStart.cap(4).toInt();
            programView->tcpStartInstructionView->tcpStartClientIpVec[2] = rx_tcpStart.cap(5).toInt();
            programView->tcpStartInstructionView->tcpStartClientIpVec[3] = rx_tcpStart.cap(6).toInt();

        }
        else if(rx_tcpStart.cap(10) == "CLIENT")
        {
            programView->tcpStartInstructionView->tcpStartType = E_TCP_START_CLIENT;

            programView->tcpStartInstructionView->tcpStartServerIpVec[0] = rx_tcpStart.cap(3).toInt();
            programView->tcpStartInstructionView->tcpStartServerIpVec[1] = rx_tcpStart.cap(4).toInt();
            programView->tcpStartInstructionView->tcpStartServerIpVec[2] = rx_tcpStart.cap(5).toInt();
            programView->tcpStartInstructionView->tcpStartServerIpVec[3] = rx_tcpStart.cap(6).toInt();

        }
        programView->tcpStartInstructionView->jmpLabelValue = rx_tcpStart.cap(14).toInt();
        programView->tcpStartInstructionView->noteStr = rx_tcpStart.cap(16);

        programView->tcpStartInstructionView->updateView();
    }
}

void ProgramDelegate::analysisTcpReadInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_TCP_READ;
    programView->editInstructionViewShowOrHide();

    qDebug() << "CurrentInstruction = " << programView->currentLineInstruction;

    QString str_tcpRead = QString("%1%2%3%4%5%6%7%8")
            .arg("\\s*(TCP_READ)\\s*")
            .arg("(R\\[(\\-?\\d+)\\])\\s*,\\s*")
            .arg("(R\\[(\\-?\\d+)\\])\\s*,\\s*")
            .arg("((\\-?\\d+)\\.(\\-?\\d+)\\.(\\-?\\d+)\\.(\\-?\\d+))\\s*,\\s*")
            .arg("(\\-?\\d+)\\s*,\\s*")
            .arg("(SERVER|CLIENT)\\s*,\\s*")
            .arg("(JMP)\\s*(LB\\[(\\-?\\d+)\\])\\s*")
            .arg("(//)\\s*(.*)");

    QRegExp rx_tcpRead(str_tcpRead);

    bool match = rx_tcpRead.exactMatch(programView->currentLineInstruction);
    if(match)
    {
//        qDebug() << "rx_tcpRead.cap(1) = " << rx_tcpRead.cap(1);
//        qDebug() << "rx_tcpRead.cap(2) = " << rx_tcpRead.cap(2);
//        qDebug() << "rx_tcpRead.cap(3) = " << rx_tcpRead.cap(3);
//        qDebug() << "rx_tcpRead.cap(4) = " << rx_tcpRead.cap(4);
//        qDebug() << "rx_tcpRead.cap(5) = " << rx_tcpRead.cap(5);
//        qDebug() << "rx_tcpRead.cap(6) = " << rx_tcpRead.cap(6);
//        qDebug() << "rx_tcpRead.cap(7) = " << rx_tcpRead.cap(7);
//        qDebug() << "rx_tcpRead.cap(8) = " << rx_tcpRead.cap(8);
//        qDebug() << "rx_tcpRead.cap(9) = " << rx_tcpRead.cap(9);
//        qDebug() << "rx_tcpRead.cap(10) = " << rx_tcpRead.cap(10);
//        qDebug() << "rx_tcpRead.cap(11) = " << rx_tcpRead.cap(11);
//        qDebug() << "rx_tcpRead.cap(12) = " << rx_tcpRead.cap(12);
//        qDebug() << "rx_tcpRead.cap(13) = " << rx_tcpRead.cap(13);
//        qDebug() << "rx_tcpRead.cap(14) = " << rx_tcpRead.cap(14);
//        qDebug() << "rx_tcpRead.cap(15) = " << rx_tcpRead.cap(15);
//        qDebug() << "rx_tcpRead.cap(16) = " << rx_tcpRead.cap(16);
//        qDebug() << "rx_tcpRead.cap(17) = " << rx_tcpRead.cap(17);
//        qDebug() << "rx_tcpRead.cap(18) = " << rx_tcpRead.cap(18);
//        qDebug() << "rx_tcpRead.cap(19) = " << rx_tcpRead.cap(19);
//        qDebug() << "rx_tcpRead.cap(20) = " << rx_tcpRead.cap(20);
//        qDebug() << "rx_tcpRead.cap(21) = " << rx_tcpRead.cap(21);

        programView->tcpReadInstructionView->tcpReadRegBeginAddress = rx_tcpRead.cap(3).toInt();
        programView->tcpReadInstructionView->tcpReadRegLength = rx_tcpRead.cap(5).toInt();

        if(rx_tcpRead.cap(12) == tr("SERVER"))
        {
            programView->tcpReadInstructionView->tcpReadClientIPVec[0] = rx_tcpRead.cap(7).toInt();
            programView->tcpReadInstructionView->tcpReadClientIPVec[1] = rx_tcpRead.cap(8).toInt();
            programView->tcpReadInstructionView->tcpReadClientIPVec[2] = rx_tcpRead.cap(9).toInt();
            programView->tcpReadInstructionView->tcpReadClientIPVec[3] = rx_tcpRead.cap(10).toInt();
            programView->tcpReadInstructionView->tcpReadBusType = E_TCP_READ_BUS_SERVER;
        }
        else if(rx_tcpRead.cap(12) == tr("CLIENT"))
        {
            programView->tcpReadInstructionView->tcpReadServerIPVec[0] = rx_tcpRead.cap(7).toInt();
            programView->tcpReadInstructionView->tcpReadServerIPVec[1] = rx_tcpRead.cap(8).toInt();
            programView->tcpReadInstructionView->tcpReadServerIPVec[2] = rx_tcpRead.cap(9).toInt();
            programView->tcpReadInstructionView->tcpReadServerIPVec[3] = rx_tcpRead.cap(10).toInt();
            programView->tcpReadInstructionView->tcpReadBusType = E_TCP_READ_BUS_CLIENT;
        }

        programView->tcpReadInstructionView->tcpReadPort = rx_tcpRead.cap(11).toInt();
        programView->tcpReadInstructionView->jmpLBValue = rx_tcpRead.cap(15).toInt();
        programView->tcpReadInstructionView->noteStr = rx_tcpRead.cap(17);

        programView->tcpReadInstructionView->updateView();
    }
}

void ProgramDelegate::analysisMoveFreeInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MOVE_FREE;
    programView->editInstructionViewShowOrHide();

    Line lineOut;
    programRegExp->patMoveFree(programView->currentLineInstruction,lineOut);
        // 运行点位类型
        if(E_MOVE_FREE_POINTS_ARRY_DP == lineOut.moveFreeInstruction.pointArryType)
        {
            programView->moveFreeInstructionView->pointType = E_MOVE_FREE_POINTS_ARRY_DP;
            programView->moveFreeInstructionView->singlePointValue =lineOut.moveFreeInstruction.pointsValue;
//                    qDebug() << "moveFreeInstructionView->SinglePointValue = " << programView->moveFreeInstructionView->singlePointValue;
        }
        else if(E_MOVE_FREE_POINTS_ARRY_DPR == lineOut.moveFreeInstruction.pointArryType)
        {
            programView->moveFreeInstructionView->pointType = E_MOVE_FREE_POINTS_ARRY_DPR;
            programView->moveFreeInstructionView->registerPointValue = lineOut.moveFreeInstruction.registerPointsValue;
//                    qDebug() << "moveFreeInstructionView->registerPointValue = " << programView->moveFreeInstructionView->registerPointValue;
        }
        else if(E_MOVE_FREE_POINTS_ARRY_DPL == lineOut.moveFreeInstruction.pointArryType)
        {
            programView->moveFreeInstructionView->pointType = E_MOVE_FREE_POINTS_ARRY_DPL;
            programView->moveFreeInstructionView->trackFile = lineOut.moveFreeInstruction.trackMoveFileName;
//                    qDebug() << "moveFreeInstructionView->trackFile = " << programView->moveFreeInstructionView->trackFile;
        }

        // 运行速度
        programView->moveFreeInstructionView->velocityRatio =  lineOut.moveFreeInstruction.velocityRatio;
//                qDebug() << "moveFreeInstructionView->velocityRatio = " << programView->moveFreeInstructionView->velocityRatio;

        // 导航模式
        if(E_MOVE_FREE_WHEEL == lineOut.moveFreeInstruction.moveFreeMode)
        {
            programView->moveFreeInstructionView->navigationMode = E_NAVIGATION_TYPE_WHEEL;
        }
        else if(E_MOVE_FREE_IMU == lineOut.moveFreeInstruction.moveFreeMode)
        {
            programView->moveFreeInstructionView->navigationMode = E_NAVIGATION_TYPE_IMU;
        }
        else if(E_MOVE_FREE_LASER == lineOut.moveFreeInstruction.moveFreeMode)
        {
            programView->moveFreeInstructionView->navigationMode = E_NAVIGATION_TYPE_LASER;
        }

        // CNT平滑系数
        programView->moveFreeInstructionView->moveFreeMoveTypeView->cntValue = lineOut.moveFreeInstruction.CNT_Value;
//                qDebug() << "moveFreeInstructionView->cntValue = " << programView->moveFreeInstructionView->cntValue;

        // 运动轨迹类型
        if(E_MOVE_FREE_MOVE_TRAJECTORY_AUTO == lineOut.moveFreeInstruction.moveFreeMoveTrajectoryType)
        {
            programView->moveFreeInstructionView->moveFreeMoveTypeView->moveFreeMoveTrajectoryType = E_MOVE_FREE_MOVE_TRAJECTORY_AUTO;
        }
        else if(E_MOVE_FREE_MOVE_TRAJECTORY_LINE == lineOut.moveFreeInstruction.moveFreeMoveTrajectoryType)
        {
            programView->moveFreeInstructionView->moveFreeMoveTypeView->moveFreeMoveTrajectoryType = E_MOVE_FREE_MOVE_TRAJECTORY_LINE;
        }
        else if(E_MOVE_FREE_MOVE_TRAJECTORY_SPLINE == lineOut.moveFreeInstruction.moveFreeMoveTrajectoryType)
        {
            programView->moveFreeInstructionView->moveFreeMoveTypeView->moveFreeMoveTrajectoryType = E_MOVE_FREE_MOVE_TRAJECTORY_SPLINE;
        }
        else if(E_MOVE_FREE_MOVE_TRAJECTORY_ROTATE == lineOut.moveFreeInstruction.moveFreeMoveTrajectoryType)
        {
            programView->moveFreeInstructionView->moveFreeMoveTypeView->moveFreeMoveTrajectoryType = E_MOVE_FREE_MOVE_TRAJECTORY_ROTATE;
        }
//            qDebug() << "moveFreeInstructionView->moveFreeMoveTrajectoryType = " << programView->moveFreeInstructionView->moveFreeMoveTrajectoryType;

        // 正向丶反向运行
        if( lineOut.moveFreeInstruction.isPositiveDirection)
        {
            programView->moveFreeInstructionView->moveFreeMoveType = E_MOVE_FREE_MOVE_P;
        }
        else
        {
            programView->moveFreeInstructionView->moveFreeMoveType = E_MOVE_FREE_MOVE_N;
        }

        // 停车精度
        programView->moveFreeInstructionView->moveFreeMoveTypeView->allowAccuracy = lineOut.moveFreeInstruction.allowAccuracy;

        //　点位类型
        if(EM_MOVE_FREE_DP == lineOut.moveFreeInstruction.pointSensorType)
        {
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->pointType = EM_MOVE_FREE_DP;
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->typeIndex = 0;
        }
        else if(EM_MOVE_FREE_VMARK == lineOut.moveFreeInstruction.pointSensorType)
        {
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->pointType = EM_MOVE_FREE_VMARK;
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->typeIndex = lineOut.moveFreeInstruction.pointIndex;
        }
        else if(EM_MOVE_FREE_QR == lineOut.moveFreeInstruction.pointSensorType)
        {
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->pointType = EM_MOVE_FREE_QR;
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->typeIndex = lineOut.moveFreeInstruction.pointIndex;
        }
        else if(EM_MOVE_FREE_CU1 == lineOut.moveFreeInstruction.pointSensorType)
        {
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->pointType = EM_MOVE_FREE_CU1;
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->typeIndex = lineOut.moveFreeInstruction.pointIndex;
        }

        //跟线策略
        if(E_PATH_CONTROL_STRATEGY_MCCRUM == lineOut.moveFreeInstruction.pathControlStrategy)
        {
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->pathControlStrategy=E_PATH_CONTROL_STRATEGY_MCCRUM;
        }
        else
        {
            programView->moveFreeInstructionView->moveFreeVmarkSettingView->pathControlStrategy=E_PATH_CONTROL_STRATEGY_DIFFERENTIAL;
        }

        // 激光过滤类型
         programView->moveFreeInstructionView->moveFreeVmarkSettingView->laserTypeNum = lineOut.moveFreeInstruction.laserTypeNum;


        // 障碍物检测
        if(lineOut.moveFreeInstruction.isDetectBarrier)
        {
            programView->moveFreeInstructionView->moveFreeMoveTypeView->detectBarrierState = E_MOVE_FREE_DETECT_BARRIER_YES;
        }
        else
        {
            programView->moveFreeInstructionView->moveFreeMoveTypeView->detectBarrierState = E_MOVE_FREE_DETECT_BARRIER_NO;
        }
         programView->moveFreeInstructionView->moveFreeMoveTypeView->barrierRunMode = lineOut.moveFreeInstruction.barrierRunMode;

        // 异常跳转标签
        programView->moveFreeInstructionView->moveFreeVmarkSettingView->jmpLbValue = lineOut.moveFreeInstruction.jmpLabel;
        // 指令注释
        programView->moveFreeInstructionView->annotation = lineOut.moveFreeInstruction.noteStr;

        programView->moveFreeInstructionView->updateView();

}

void ProgramDelegate::analysisPrRegisterInstruction()
{


//        QRegExp rx3("\\s*\\[\\s*([GP]{0,2}\\s*\\d*\\s*\\:?\\s*[R]?\\s*\\[?\\s*\\d*)\\s*(\\]?)\\s*\\,?\\s*([R]?\\s*\\[?\\s*\\w*)\\s*\\]\\s*(\\]?)\\s*(.*)");
//        QRegExp rx4("\\s*\\=\\s*([\\w\\[\\]\\+\\-\\*\\/\\,\\s]*)\\s*[\\/\\;\\s]*\\s*([\\w\\s\\(\\)\\.]*)");
//        rx2.cap(2).indexOf(rx3);
//        rx3.cap(5).indexOf(rx4);

//        if("" == rx3.cap(3))
//        {
//            programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_PR_I;
//            programView->registerInstructionView->pRIndex = rx3.cap(1) + rx3.cap(2);
//            programView->registerInstructionView->pRIValue = rx4.cap(1);
//        }
//        else
//        {
//            programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_PR_IJ;
//            programView->registerInstructionView->iIndex = rx3.cap(1) + rx3.cap(2);
//            programView->registerInstructionView->jIndex = rx3.cap(3) + rx3.cap(4);
//            programView->registerInstructionView->pRIJValue = rx4.cap(1);
//        }

//        programView->registerInstructionView->note = rx4.cap(2);

    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_REGISTER;

    programView->editInstructionViewShowOrHide();


    Line lineOut;
    programRegExp->patRegPr(programView->currentLineInstruction,lineOut);
    if( E_PR_INS_TYPE_PRIJ_CONST==lineOut.prRegisterInstruction.instructionType||
           E_PR_INS_TYPE_PRIJ_MINUS_PRIJ==lineOut.prRegisterInstruction.instructionType||
           E_PR_INS_TYPE_PRIJ_MINUS_CONST==lineOut.prRegisterInstruction.instructionType)
    {
        programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_PR_IJ;
        programView->registerInstructionView->iIndex = QString::number(lineOut.prRegisterInstruction.left_index_i);
        programView->registerInstructionView->jIndex = QString::number(lineOut.prRegisterInstruction.left_index_j);
        if( E_PR_INS_TYPE_PRIJ_CONST==lineOut.prRegisterInstruction.instructionType)
        {
            programView->registerInstructionView->pRIJValue = QString::number(lineOut.prRegisterInstruction.constValue);
        }
        else if( E_PR_INS_TYPE_PRIJ_MINUS_PRIJ==lineOut.prRegisterInstruction.instructionType)
        {
            QString tmpStr;
            if(-1==lineOut.prRegisterInstruction.right_operate1)
            {
                tmpStr="-PR[";
            }
            else
            {
                tmpStr="PR[";
            }

            tmpStr+=QString::number(lineOut.prRegisterInstruction.right_index_i)+",";
            tmpStr+=QString::number(lineOut.prRegisterInstruction.right_index_j)+"]";
            if(-1==lineOut.prRegisterInstruction.right_operate2)
            {
                tmpStr+="-PR[";
            }
            else
            {
                tmpStr+="+PR[";
            }
            tmpStr+=QString::number(lineOut.prRegisterInstruction.right2_index_i)+",";
            tmpStr+=QString::number(lineOut.prRegisterInstruction.right2_index_j)+"]";

            programView->registerInstructionView->pRIJValue = tmpStr;
        }
        else if( E_PR_INS_TYPE_PRIJ_MINUS_CONST==lineOut.prRegisterInstruction.instructionType)
        {
            QString tmpStr;
            if(-1==lineOut.prRegisterInstruction.right_operate1)
            {
                tmpStr="-PR[";
            }
            else
            {
                tmpStr="PR[";
            }

            tmpStr+=QString::number(lineOut.prRegisterInstruction.right_index_i)+",";
            tmpStr+=QString::number(lineOut.prRegisterInstruction.right_index_j)+"]";
            if(lineOut.prRegisterInstruction.constValue>0.0000001)
            {
                tmpStr+="+"+QString::number(lineOut.prRegisterInstruction.constValue);
            }
            else if(lineOut.prRegisterInstruction.constValue<-0.0000001)
            {
                tmpStr+=QString::number(lineOut.prRegisterInstruction.constValue);
            }



            programView->registerInstructionView->pRIJValue = tmpStr;
        }
    }
    else if( E_PR_INS_TYPE_PRI_PRI==lineOut.prRegisterInstruction.instructionType||
           E_PR_INS_TYPE_PRI_MINUS_PRI==lineOut.prRegisterInstruction.instructionType)
    {
        programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_PR_I;
        programView->registerInstructionView->pRIndex = QString::number(lineOut.prRegisterInstruction.left_index_i);
        if( E_PR_INS_TYPE_PRI_PRI==lineOut.prRegisterInstruction.instructionType)
        {
            QString tmpStr;
            if(-1==lineOut.prRegisterInstruction.right_operate1)
            {
                tmpStr="-PR[";
            }
            else
            {
                tmpStr="PR[";
            }

            tmpStr+=QString::number(lineOut.prRegisterInstruction.right_index_i)+"]";


            programView->registerInstructionView->pRIValue = tmpStr;
        }
        else if( E_PR_INS_TYPE_PRI_MINUS_PRI==lineOut.prRegisterInstruction.instructionType)
        {
            QString tmpStr;
            if(-1==lineOut.prRegisterInstruction.right_operate1)
            {
                tmpStr="-PR[";
            }
            else
            {
                tmpStr="PR[";
            }

            tmpStr+=QString::number(lineOut.prRegisterInstruction.right_index_i)+"]";
            if(-1==lineOut.prRegisterInstruction.right_operate2)
            {
                tmpStr+="-PR[";
            }
            else
            {
                tmpStr+="+PR[";
            }

            tmpStr+=QString::number(lineOut.prRegisterInstruction.right2_index_i)+"]";


            programView->registerInstructionView->pRIValue = tmpStr;
        }

    }
    else if( E_PR_INS_TYPE_PRI_LPS==lineOut.prRegisterInstruction.instructionType||
           E_PR_INS_TYPE_PRI_JPS==lineOut.prRegisterInstruction.instructionType)
    {
        programView->registerInstructionView->selectRegisterType = EM_REGISTER_TYPE_PR_I;
        programView->registerInstructionView->pRIndex = QString::number(lineOut.prRegisterInstruction.left_index_i);
        if( E_PR_INS_TYPE_PRI_LPS==lineOut.prRegisterInstruction.instructionType)
        {

            programView->registerInstructionView->pRIValue = "LPOS";
        }
        else
        {
            programView->registerInstructionView->pRIValue = "JPOS";
        }

    }

    programView->registerInstructionView->note=lineOut.prRegisterInstruction.comment;

    programView->registerInstructionView->updateView();


}

void ProgramDelegate::analysisMoveMagInstruction()
{
    // 指令属性界面标志
    programView->instructionListFlag = 1;
    // 指令属性页面号
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MOVE_MAG;
    // 根据页面号显示
    programView->editInstructionViewShowOrHide();

    // 正则表达式匹配提取显示内容
    QString moveMagPat;
    moveMagPat = QString("%1%2%3%4%5")
            .arg("\\s*(MOVE_MAG)\\s*")
            .arg("(L|M|R)\\s*(FRONT|BACK)\\s*(0|100|[0-9]{1,2})(%)\\s*(,)\\s*")
            .arg("(RFID)\\s*(\\-?\\d+)\\s*")
            .arg("(\\s|,(RFID_STOP)|,(MAG_STOP)|,(INPUT\\s*(\\-?\\d+)))\\s*")
            .arg("(//)\\s*(.*)");

    // 创建正则表达式对象匹配提取指令参数
    QRegExp rxMoveMag(moveMagPat);

    bool match = rxMoveMag.exactMatch(programView->currentLineInstruction);
    if(match)
    {
        qDebug() << " currentLineInstruction: " << programView->currentLineInstruction;
        if("L" == rxMoveMag.cap(2))
        {
            programView->moveMagInstructionView->leftMiddleRight = 0;
        }
        else if("M" == rxMoveMag.cap(2))
        {
            programView->moveMagInstructionView->leftMiddleRight = 1;
        }
        else if("R" == rxMoveMag.cap(2))
        {
            programView->moveMagInstructionView->leftMiddleRight = 2;
        }

        if("FRONT" == rxMoveMag.cap(3))
        {
            programView->moveMagInstructionView->frontBack = 0;
        }
        else if("BACK" == rxMoveMag.cap(3))
        {
            programView->moveMagInstructionView->frontBack = 1;
        }

        programView->moveMagInstructionView->velocityRatio = rxMoveMag.cap(4).toInt();
        programView->moveMagInstructionView->rfidValue = rxMoveMag.cap(8);

        if(rxMoveMag.cap(9) == " ")
        {
            programView->moveMagInstructionView->stopType = E_MOVE_MAG_NO_STOP;
            programView->moveMagInstructionView->stopInputNum = 0;
        }
        else if(rxMoveMag.cap(10) == "RFID_STOP")
        {
            programView->moveMagInstructionView->stopType = E_MOVE_MAG_RFID_STOP;
            programView->moveMagInstructionView->stopInputNum = 0;
        }
        else if(rxMoveMag.cap(11) == "MAG_STOP")
        {
            programView->moveMagInstructionView->stopType = E_MOVE_MAG_MAG_WIDTH_STOP;
            programView->moveMagInstructionView->stopInputNum = 0;
        }
        else if(rxMoveMag.cap(12).contains("INPUT"))
        {
            programView->moveMagInstructionView->stopType = E_MOVE_MAG_INPUT_STOP;
            programView->moveMagInstructionView->stopInputNum = rxMoveMag.cap(13).toInt();
        }

        programView->moveMagInstructionView->annotationStr = rxMoveMag.cap(15);

        // 刷新界面内容
        programView->moveMagInstructionView->updateView();
    }
}

void ProgramDelegate::analysisModbusStartInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_MODBUS_START;
    programView->editInstructionViewShowOrHide();

    QString modbusStartPat  = QString("%1%2%3%4")
                         .arg("\\s*(MODBUS_START)\\s*,")
                         .arg("\\s*(\\-?\\d+)\\s*,")
                         .arg("\\s*(INTERNET|RS485)\\s*,\\s*(MASTER|SLAVE)\\s*,\\s*(JMP)\\s*(LB\\[(\\-?\\d+)\\])\\s*")
                         .arg("(//)\\s*(.*)");

    QRegExp rxModbusStart(modbusStartPat);

//            programView->currentLineInstruction.indexOf(rxModbusStart);
    bool match;
    qDebug() << " currentLineInstruction: " << programView->currentLineInstruction;

    if((match = rxModbusStart.exactMatch(programView->currentLineInstruction)) == true)
    {
        programView->modbusStartInstructionView->modbusID = rxModbusStart.cap(2).toInt();

        if((rxModbusStart.cap(3) == "INTERNET") && (rxModbusStart.cap(4) == "MASTER"))
        {
            programView->modbusStartInstructionView->modbusSpecType = E_MODBUS_SPEC_TYPE_INTERNET_MASTER;
        }
        else if((rxModbusStart.cap(3) == "INTERNET") && (rxModbusStart.cap(4) == "SLAVE"))
        {
            programView->modbusStartInstructionView->modbusSpecType = E_MODBUS_SPEC_TYPE_INTERNET_SLAVE;
        }
        else if((rxModbusStart.cap(3) == "RS485") && (rxModbusStart.cap(4) == "MASTER"))
        {
            programView->modbusStartInstructionView->modbusSpecType = E_MODBUS_SPEC_TYPE_RS485_MASTER;
        }
        else if((rxModbusStart.cap(3) == "RS485") && (rxModbusStart.cap(4) == "SLAVE"))
        {
            programView->modbusStartInstructionView->modbusSpecType = E_MODBUS_SPEC_TYPE_RS485_SLAVE;
        }
        else
        {
            programView->modbusStartInstructionView->modbusSpecType = E_MODBUS_SPEC_TYPE_ERROR;
        }

        if(rxModbusStart.cap(5) == "JMP")
        {
            programView->modbusStartInstructionView->JMP_LB_Velue = rxModbusStart.cap(7).toInt();
        }

        programView->modbusStartInstructionView->noteStr = rxModbusStart.cap(9);
        programView->modbusStartInstructionView->updateView();
    }
}

void ProgramDelegate::analysisModbusReadInstruction(QString programStr)
{

    Line lineOut;
    programRegExp->patModbusRead(programStr,lineOut);


    programView->modbusReadInstructionView->regReadValue = lineOut.modbusReadInstruction.modbusReadDataRegisterIndex;
    programView->modbusReadInstructionView->regAddress = lineOut.modbusReadInstruction.modbuReadRegAddress;
    programView->modbusReadInstructionView->modbusId = lineOut.modbusReadInstruction.busId;

    switch(lineOut.modbusReadInstruction.modbusType)
    {
    case E_MODBUS_SPEC_TYPE_INTERNET_MASTER:
    {
        programView->modbusReadInstructionView->modbusType = E_MODBUS_TYPE_INTERNET_MASTER;
        break;
    }
    case E_MODBUS_SPEC_TYPE_INTERNET_SLAVE:
    {
        programView->modbusReadInstructionView->modbusType = E_MODBUS_TYPE_INTERNET_SLAVE;
        break;
    }
    case E_MODBUS_SPEC_TYPE_RS485_MASTER:
    {
        programView->modbusReadInstructionView->modbusType = E_MODBUS_TYPE_RS485_MASTER;
        break;
    }
    case E_MODBUS_SPEC_TYPE_RS485_SLAVE:
    {
        programView->modbusReadInstructionView->modbusType = E_MODBUS_TYPE_RS485_SLAVE;
        break;
    }
    }

    programView->modbusReadInstructionView->JMP_LB_Value = lineOut.modbusReadInstruction.jmpLable;

    programView->modbusReadInstructionView->noteStr = lineOut.modbusReadInstruction.noteStr;


}

void ProgramDelegate::analysisModbusWriteInstruction(QString programStr)
{

    Line lineOut;
    programRegExp->patModbusWrite(programStr,lineOut);


    if(REG_CONST==lineOut.modbusWriteInstruction.writeSourceType)
    {
        programView->modbusWriteInstructionView->selectionWriteValueType = E_SELECTION_NO_CONST;
        programView->modbusWriteInstructionView->writeValue = lineOut.modbusWriteInstruction.robotRegisterIndex;
    }
    else
    {
        programView->modbusWriteInstructionView->selectionWriteValueType = E_SELECTION_CONST;
        programView->modbusWriteInstructionView->writeConstValue = lineOut.modbusWriteInstruction.constWriteData;
    }

    programView->modbusWriteInstructionView->writeRegAddress = lineOut.modbusWriteInstruction.modbuWriteRegAddress;
    programView->modbusWriteInstructionView->modbusID = lineOut.modbusWriteInstruction.busId;

    switch(lineOut.modbusWriteInstruction.modbusType)
    {
    case E_MODBUS_SPEC_TYPE_INTERNET_MASTER:
    {
        programView->modbusWriteInstructionView->selectionModbusType = E_SELECTION_INTERNET;
        programView->modbusWriteInstructionView->selectionModbusMode = E_SELECTION_MASTER;
        programView->modbusWriteInstructionView->modbusWriteType = E_MODBUS_WRITE_TYPE_INTERNET_MASTER;
        break;
    }
    case E_MODBUS_SPEC_TYPE_INTERNET_SLAVE:
    {
        programView->modbusWriteInstructionView->selectionModbusType = E_SELECTION_INTERNET;
        programView->modbusWriteInstructionView->selectionModbusMode = E_SELECTION_SLAVE;
        programView->modbusWriteInstructionView->modbusWriteType = E_MODBUS_WRITE_TYPE_INTERNET_SLAVE;
        break;
    }
    case E_MODBUS_SPEC_TYPE_RS485_MASTER:
    {
        programView->modbusWriteInstructionView->selectionModbusType = E_SELECTION_RS485;
        programView->modbusWriteInstructionView->selectionModbusMode = E_SELECTION_MASTER;
        programView->modbusWriteInstructionView->modbusWriteType = E_MODBUS_WRITE_TYPE_RS485_MASTER;
        break;
    }
    case E_MODBUS_SPEC_TYPE_RS485_SLAVE:
    {
        programView->modbusWriteInstructionView->selectionModbusType = E_SELECTION_RS485;
        programView->modbusWriteInstructionView->selectionModbusMode = E_SELECTION_SLAVE;
        programView->modbusWriteInstructionView->modbusWriteType = E_MODBUS_WRITE_TYPE_RS485_SLAVE;
        break;
    }
    }


    programView->modbusWriteInstructionView->JMP_LB_Value = lineOut.modbusWriteInstruction.jmpLable;
    programView->modbusWriteInstructionView->noteStr = lineOut.modbusWriteInstruction.noteStr;


}

void ProgramDelegate::analysisSetOdomInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_SET_ODOM;
    programView->editInstructionViewShowOrHide();

    QString str_rx_float = "(\\s*(\\-?\\d+)(\\.\\d+)?\\s*)";
    QString str_setOdomPat = QString("%1%2%3%4%5")
            .arg("\\s*(SET_ODOM)")
            .arg(QString("%1%2").arg(str_rx_float).arg(","))
            .arg(QString("%1%2").arg(str_rx_float).arg(","))
            .arg(str_rx_float)
            .arg("(//)\\s*(.*)");
    QRegExp rx_setOdom(str_setOdomPat);

    qDebug() << "CurrentInstructionStr : " << programView->currentLineInstruction;
    bool match = rx_setOdom.exactMatch(programView->currentLineInstruction);
    if(match)
    {
        programView->odometryInstructionView->posX = rx_setOdom.cap(2).toDouble();
        programView->odometryInstructionView->posY = rx_setOdom.cap(5).toDouble();
        programView->odometryInstructionView->posR = rx_setOdom.cap(8).toDouble();
        programView->odometryInstructionView->noteStr = rx_setOdom.cap(12);

        programView->odometryInstructionView->updataView();
    }
}

void ProgramDelegate::analysisLoadMapInstruction()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_LOAD_MAP;
    programView->editInstructionViewShowOrHide();

    qDebug() << "CurrentInstruction = " << programView->currentLineInstruction;

    QString str_loadMap = QString("%1%2%3%4")
            .arg("\\s*(LOAD_MAP)\\s*")
            .arg("([\\s\\S]*),\\s*")
            .arg("\\s*(JMP\\s*LB\\[(\\d+)\\])\\s*")
            .arg("\\s*(//)\\s*(.*)");

    QRegExp rx_LoadMap(str_loadMap);
    if(rx_LoadMap.exactMatch(programView->currentLineInstruction))
    {
//        qDebug() << "rx_loadMap[1]:" << rx_LoadMap.cap(1);
//        qDebug() << "rx_loadMap[2]:" << rx_LoadMap.cap(2).remove(QRegExp("\\s"));
//        qDebug() << "rx_loadMap[3]:" << rx_LoadMap.cap(3);
//        qDebug() << "rx_loadMap[4]:" << rx_LoadMap.cap(4);
//        qDebug() << "rx_loadMap[5]:" << rx_LoadMap.cap(5);
//        qDebug() << "rx_loadMap[6]:" << rx_LoadMap.cap(6);
//        qDebug() << "rx_loadMap[7]:" << rx_LoadMap.cap(7);

        programView->loadMapInstructionView->mapFileName = rx_LoadMap.cap(2).remove(QRegExp("\\s"));
        programView->loadMapInstructionView->jmpLabel = rx_LoadMap.cap(4);
        programView->loadMapInstructionView->noteStr = rx_LoadMap.cap(6);

        programView->loadMapInstructionView->updateView();
    }
}
int ProgramDelegate::patCheckBattery(QString programStr)
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_CHECK_BATTERY;
    programView->editInstructionViewShowOrHide();

    qDebug() << "CurrentInstruction = " << programView->currentLineInstruction;

    Line lineOut;
    programRegExp->patCheckBattery(programStr,lineOut);

    programView->checkBatteryView->batteryElectricQuantity =
            QString::number(lineOut.checkBatteryInstruction.electricQuantity);
    programView->checkBatteryView->batteryLBLIndex = lineOut.checkBatteryInstruction.labelIndex;
    programView->checkBatteryView->note = "";

    programView->checkBatteryView->updateView();

}
void ProgramDelegate::analysisWaitCommand()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_WAIT_COMMAND;
    programView->editInstructionViewShowOrHide();

    qDebug() << "CurrentInstruction = " << programView->currentLineInstruction;

    QString str_waitCommand = QString("%1%2%3%4")
            .arg("\\s*(WAIT_COMMAND)")
            .arg("\\s*(R)\\[(\\d+)\\]\\s*,")
            .arg("\\s*(TIMEOUT)\\s*(\\d+)\\s*,")
            .arg("\\s*(JMP)\\s*(LBL\\[(\\w+)\\])\\s*//(.*)");

    QRegExp rx_waitCommand(str_waitCommand);
    if(rx_waitCommand.exactMatch(programView->currentLineInstruction))
    {
        programView->waitCommandView->registerIndex=rx_waitCommand.cap(3).toInt();
        programView->waitCommandView->waitMaxTime=rx_waitCommand.cap(5).toInt();
        programView->waitCommandView->timeOutLabel=rx_waitCommand.cap(8);
        programView->waitCommandView->note=rx_waitCommand.cap(9);
        programView->waitCommandView->updateView();
    }
}

void ProgramDelegate::analysisRobotMove()
{
    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_ROBOT_MOVE;
    programView->editInstructionViewShowOrHide();

    qDebug() << "CurrentInstruction = " << programView->currentLineInstruction;

    // 指令格式: ROBOT_MOVE [sendParameter],[waitParameter],TIMEOUT 1,JMP LBL[1]  //
    QString str_robotMove = QString("%1%2%3%4%5%6%7%8")
            .arg("\\s*(ROBOT_MOVE)")
            .arg("\\s*(IP\\[(.*)\\])\\s*,")
            .arg("\\s*(PORT\\[(\\d+)\\])\\s*,")
            .arg("\\s*(SERVER|CLIENT)\\s*,")
            .arg("\\s*SEND\\[(.*)\\]\\s*,")
            .arg("\\s*WAIT\\[(.*)\\]\\s*,")
            .arg("\\s*(TIMEOUT)\\s*(\\d+)\\s*,")
            .arg("\\s*(JMP)\\s*(LBL\\[(\\w+)\\])\\s*//(.*)");

    QRegExp rx_robotMove(str_robotMove);
    if(rx_robotMove.exactMatch(programView->currentLineInstruction))
    {
        if(rx_robotMove.cap(6) == tr("SERVER"))
        {
            programView->robotMoveInstructionView->robotMoveBusType = EM_ROBOT_MOVE_BUS_SERVER;
            programView->robotMoveInstructionView->localIP = rx_robotMove.cap(3);
            programView->robotMoveInstructionView->serverIP = "192.168.0.0";
        }
        else if(rx_robotMove.cap(6) == tr("CLIENT"))
        {
            programView->robotMoveInstructionView->robotMoveBusType = EM_ROBOT_MOVE_BUS_CLIENT;
            programView->robotMoveInstructionView->serverIP = rx_robotMove.cap(3);
            programView->robotMoveInstructionView->localIP = "127.0.0.1";
        }

        programView->robotMoveInstructionView->communicationPort = rx_robotMove.cap(5).toInt();
        programView->robotMoveInstructionView->sendParameterStr = rx_robotMove.cap(7);
        programView->robotMoveInstructionView->waitParameterStr = rx_robotMove.cap(8);
        programView->robotMoveInstructionView->timeOutValue = rx_robotMove.cap(10).toInt();
        programView->robotMoveInstructionView->jmpLableValue = rx_robotMove.cap(13);
        programView->robotMoveInstructionView->noteStr = rx_robotMove.cap(14);
        programView->robotMoveInstructionView->updateView();
    }
}


void ProgramDelegate::analysisRoller()
{

    programView->instructionListFlag = 1;
    programView->editInstructionViewIndex = EM_EDIT_INSTRUCTION_ROLLER;
    programView->editInstructionViewShowOrHide();

    qDebug() << "Current Instruction :" << programView->currentLineInstruction;

    QString str_roller = QString("%1%2%3%4%5%6")
            .arg("(ROLLER)\\s*")
            .arg("(General|Heavy),\\s*")
            .arg("(P|R|A|B),\\s*")
            .arg("(\\-?\\d+),\\s*")
            .arg("(JMP)\\s*(LB\\[(\\-?\\d+)\\])\\s*")
            .arg("(//)\\s*(.*)");

    QRegExp rxRoller(str_roller);
    if(rxRoller.exactMatch(programView->currentLineInstruction))
    {
//        if(rxRoller.cap(2).contains(tr("General")))
//        {
//             programView->rollerInstructionView->rollerType = E_ROLLER_GENERAL;
//        }
//        else if(rxRoller.cap(2).contains(tr("Heavy")))
//        {
//             programView->rollerInstructionView->rollerType = E_ROLLER_HEAVY;
//        }
//        else
//        {
//            programView->rollerInstructionView->rollerType = E_ROLLER_ERROR;
//        }

        if(rxRoller.cap(3) == tr("P"))
        {
            programView->rollerInstructionView->rollerDirectionType = E_ROLLER_LEFT_LOAD;
        }
        else if(rxRoller.cap(3) == tr("R"))
        {
            programView->rollerInstructionView->rollerDirectionType = E_ROLLER_LEFT_DOWNLOAD;
        }
        else if(rxRoller.cap(3) == tr("A"))
        {
            programView->rollerInstructionView->rollerDirectionType = E_ROLLER_RIGHT_LOAD;
        }
        else if(rxRoller.cap(3) == tr("B"))
        {
            programView->rollerInstructionView->rollerDirectionType = E_ROLLER_RIGHT_DOWNLOAD;
        }

        programView->rollerInstructionView->timeOutValue = rxRoller.cap(4).toInt();
        programView->rollerInstructionView->jmpLbValue = rxRoller.cap(7).toInt();
        programView->rollerInstructionView->noteStr = rxRoller.cap(9);

        programView->rollerInstructionView->updateView();
    }
}
